问题
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