Merge pull request #696 from microsoft/benibenj/selectedItemsContext

Title command uses selected Items context
This commit is contained in:
Benjamin Simmonds
2022-08-11 16:30:27 +02:00
committed by GitHub
2 changed files with 16 additions and 2 deletions

View File

@ -11,7 +11,7 @@
"url": "https://github.com/Microsoft/vscode-extension-samples"
},
"engines": {
"vscode": "^1.67.0"
"vscode": "^1.71.0"
},
"categories": [
"Other"
@ -165,6 +165,10 @@
"when": "view == nodeDependencies",
"group": "navigation"
},
{
"command": "jsonOutline.renameNode",
"when": "view == jsonOutline"
},
{
"command": "nodeDependencies.addEntry",
"when": "view == nodeDependencies"

View File

@ -26,7 +26,17 @@ export function activate(context: vscode.ExtensionContext) {
vscode.window.registerTreeDataProvider('jsonOutline', jsonOutlineProvider);
vscode.commands.registerCommand('jsonOutline.refresh', () => jsonOutlineProvider.refresh());
vscode.commands.registerCommand('jsonOutline.refreshNode', offset => jsonOutlineProvider.refresh(offset));
vscode.commands.registerCommand('jsonOutline.renameNode', offset => jsonOutlineProvider.rename(offset));
vscode.commands.registerCommand('jsonOutline.renameNode', args => {
let offset = undefined;
if(args.selectedTreeItems && args.selectedTreeItems.length){
offset = args.selectedTreeItems[0];
}else if(typeof args === 'number'){
offset = args;
}
if(offset){
jsonOutlineProvider.rename(offset);
}
});
vscode.commands.registerCommand('extension.openJsonSelection', range => jsonOutlineProvider.select(range));
// Samples of `window.createView`