VSCode: Restart an extension automatically when its source has changed

99封情书 提交于 2021-02-07 18:42:25

问题


I'm developing a VSCode extension. Is it possible to automatically have the extension reloaded when I change its source. Currently, I need to press Ctrl + SHift + F5.


回答1:


I guess your extension is written in TS/javascript, so you can use fs.watch to watch your sources, and find a way to run the vscode command workbench.action.reloadWindow, which is from sources of vscode, the function ReloadWindowAction.Run() or directly windowService.reloadWindow().

export class ReloadWindowAction extends Action {

    static readonly ID = 'workbench.action.reloadWindow';
    static LABEL = nls.localize('reloadWindow', "Reload Window");

    constructor(
        id: string,
        label: string,
        @IWindowService private windowService: IWindowService
    ) {
        super(id, label);
    }

    run(): TPromise<boolean> {
        return this.windowService.reloadWindow().then(() => true);
    }
}

It might be a tiny extension that connect those functions.



来源:https://stackoverflow.com/questions/49946649/vscode-restart-an-extension-automatically-when-its-source-has-changed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!