且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

VSCode:当扩展源发生变化时自动重启扩展

更新时间:2023-12-03 09:24:10

我猜你的扩展是用 TS/javascript 编写的,所以你可以使用 fs.watch 观看您的源代码,并找到运行 vscode 命令 workbench.action.reloadWindow 的方法,它是来自 vscode 来源,函数ReloadWindowAction.Run() 或直接windowService.reloadWindow().

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.