adding open for script

This commit is contained in:
Erich Gamma 2018-03-30 17:32:18 +02:00
parent 2ce1f53e36
commit 2b73118942
2 changed files with 19 additions and 5 deletions

View file

@ -75,17 +75,22 @@
{
"command": "npm.openScript",
"when": "view == npm && viewItem == packageJSON",
"group": "1_navigation"
"group": "navigation"
},
{
"command": "npm.runScript",
"when": "view == npm && viewItem == script",
"group": "1_navigation"
"group": "navigation@1"
},
{
"command": "npm.debugScript",
"when": "view == npm && viewItem == script",
"group": "1_navigation"
"group": "navigation@2"
},
{
"command": "npm.openScript",
"when": "view == npm && viewItem == script",
"group": "navigation@3"
}
]
},

View file

@ -162,8 +162,17 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
}
}
private async openScript(packageJSON: PackageJSON) {
let document: TextDocument = await workspace.openTextDocument(packageJSON.resourceUri!);
private async openScript(selection: PackageJSON | NpmScript) {
let uri: Uri | undefined = undefined;
if (selection instanceof PackageJSON) {
uri = selection.resourceUri!;
} else if (selection instanceof NpmScript) {
uri = selection.package.resourceUri;
}
if (!uri) {
return;
}
let document: TextDocument = await workspace.openTextDocument(uri);
window.showTextDocument(document);
}