Skip to content

Commit

Permalink
Add edit tab group name
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosedilsonjr committed Jul 8, 2024
1 parent 198f82e commit af226cb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,20 @@
"group": "vs_tab_groups_3@1"
},
{
"command": "vs_tab_groups.editTabGroupIcon",
"command": "vs_tab_groups.editTabGroupName",
"when": "view == vs_tab_groups && viewItem == vstg_root_item",
"group": "vs_tab_groups_4@0"
},
{
"command": "vs_tab_groups.removeTabGroup",
"command": "vs_tab_groups.editTabGroupIcon",
"when": "view == vs_tab_groups && viewItem == vstg_root_item",
"group": "vs_tab_groups_4@1"
},
{
"command": "vs_tab_groups.removeTabGroup",
"when": "view == vs_tab_groups && viewItem == vstg_root_item",
"group": "vs_tab_groups_4@2"
},
{
"command": "vs_tab_groups.moveUp",
"when": "view == vs_tab_groups && viewItem == vstg_child_item",
Expand Down Expand Up @@ -269,6 +274,10 @@
"command": "vs_tab_groups.editTabGroupIcon",
"title": "Edit Tab Group Icon"
},
{
"command": "vs_tab_groups.editTabGroupName",
"title": "Edit Tab Group Name"
},
{
"command": "vs_tab_groups.removeTabGroup",
"title": "Remove Tab Group",
Expand Down
22 changes: 22 additions & 0 deletions src/TreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class TreeDataProvider implements vscode.TreeDataProvider<TreeItem> {
vscode.commands.registerCommand("vs_tab_groups.closeTabGroup", (item) => this.closeTabGroup(item));
vscode.commands.registerCommand("vs_tab_groups.editTabGroupIcon", (item) => this.editTabGroupIcon(item));
vscode.commands.registerCommand("vs_tab_groups.removeTabGroup", (item) => this.removeTabGroup(item));
vscode.commands.registerCommand("vs_tab_groups.editTabGroupName", (item) => this.editTabGroupName(item));

// Low level, actions on tabs
vscode.commands.registerCommand("vs_tab_groups.openTab", (item) => this.openTab(item));
Expand Down Expand Up @@ -532,6 +533,27 @@ export class TreeDataProvider implements vscode.TreeDataProvider<TreeItem> {
}
}

/**
* Change the name of the group's root.
* @param item The item representing the root of the group.
*/
async editTabGroupName(item: TreeItem) {
const input = await vscode.window.showInputBox({
prompt: "Type in the new name of the tab group.\n",
});

if (input && input !== "") {
if (this.labelExists(input)) {
vscode.window.showErrorMessage(`Can not have two tab groups with name '${input}'`);
return;
}

item.label = input
this.m_onDidChangeTreeData.fire(undefined);
}
this.save();
}

/**
* Removes the tab group from the tree
* @param item The item representing the root of the group.
Expand Down

0 comments on commit af226cb

Please sign in to comment.