在开发新的vscode扩展时如何将新文件添加到工作区?

时间:2016-11-27 19:01:12

标签: typescript file visual-studio-code vscode-extensions

就像我遇到麻烦一样,并不是那么明显:

如何在开发vscode扩展时添加新文件?

1 个答案:

答案 0 :(得分:1)

首先你必须创建一个命令(当使用vscode扩展示例时将它放在extension.ts中) - >例如hello world命令。

您必须在工作区上使用openTextDocument方法并获取项目的路径。不要忘记你必须使用" \"而不是" /"路径:

let manifest = await vscode.workspace.openTextDocument(vscode.Uri.parse("untitled:"+vscode.workspace.rootPath+"\\projectmanifest.json"));
await manifest.save();