【发布时间】:2020-02-23 16:02:35
【问题描述】:
扩展代码是否可以设置为在 vscode 启动完成时运行?或者当一个文件夹被打开时?
如何编写一个扩展程序,在新的 vscode 窗口中打开一个文件夹,然后在该文件夹中打开一个文本文件?
我已经打开文件夹部分工作。我正在使用全局状态来存储要打开的文件的名称。
// store in name of file to open in global state.
context.globalState.update('fileToOpen', './src/index.html');
// open folder in a new vscode instance.
const uri_path = `file:///c:/web/tester/parcel`;
const uri = vscode.Uri.parse(uri_path);
await vscode.commands.executeCommand('vscode.openFolder', uri, true);
然后,当我的扩展在新的 vscode 实例中激活时,我想从全局状态读取文件名,等待 vscode 打开文件夹,然后运行openTextDocument 打开文件。
【问题讨论】:
标签: visual-studio-code vscode-extensions