selected Items context in use

This commit is contained in:
Benjamin Simmonds
2022-08-11 15:09:53 +02:00
parent e5db95e79b
commit 8cbe519d2c
2 changed files with 15 additions and 1 deletions

View File

@ -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`