Skip to content

Commit 1bfdff7

Browse files
committed
feat(quickpick): add move worktree action in the worktree quick pick menu
- Added separator items to group actions in the worktree quick pick menu - Moved "View Git history" and "Open the repository in Source Control view" into new groups - Implemented "Move Worktree" command action with appropriate icon and label - Updated QuickPickAction interface to include 'separator' and Commands.moveWorktree types - Handled moveWorktree command case in action switch statement
1 parent 3326ce4 commit 1bfdff7

5 files changed

Lines changed: 26 additions & 8 deletions

File tree

l10n/bundle.l10n.ja.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"Remove Folder from Workspace": "ワークスペースからフォルダを削除",
88
"Open Settings": "設定を開く",
99
"Remove Worktree": "ワークツリーを削除",
10+
"Move Worktree": "ワークツリーを移動",
1011
"Find Worktree": "ワークツリーを検索",
1112
"Add Worktree": "ワークツリーを追加",
1213
"Report Issue": "問題を報告",

l10n/bundle.l10n.zh-cn.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"Remove Folder from Workspace": "从工作区中移除",
88
"Open Settings": "打开设置",
99
"Remove Worktree": "移除 Worktree",
10+
"Move Worktree": "移动 Worktree",
1011
"Find Worktree": "查找 Worktree",
1112
"Add Worktree": "添加 Worktree",
1213
"Report Issue": "反馈问题",

l10n/bundle.l10n.zh-tw.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"Add Folder to Workspace": "新增至工作區",
77
"Remove Folder from Workspace": "從工作區中移除",
88
"Open Settings": "開啟設定",
9-
"Remove Worktree": "移除 Worktree",
9+
"Remove Worktree": "移動 Worktree",
10+
"Move Worktree": "移动 Worktree",
1011
"Find Worktree": "尋找 Worktree",
1112
"Add Worktree": "新增 Worktree",
1213
"Report Issue": "回報問題",

src/core/quickPick/pickAction.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class WorktreeActionPicker {
6868
const [commitDetail] = await Promise.all([getLashCommitDetail(viewItem.fsPath, ['s', 'H'])]);
6969
const template = Config.get('worktreePick.copyTemplate', '$LABEL');
7070
const isCurrent = judgeIncludeFolder(viewItem.fsPath);
71+
const separator: QuickPickAction = { kind: vscode.QuickPickItemKind.Separator, label: ' ', action: 'separator', hide: false };
7172

7273
const templateVars: TemplateVars = {
7374
hash: commitDetail.H || '',
@@ -89,7 +90,7 @@ class WorktreeActionPicker {
8990
];
9091

9192
const commandActions: QuickPickAction[] = [
92-
this.buildCommandAction({ icon: 'history', label: 'View Git history', action: Commands.viewHistory }),
93+
separator,
9394
this.buildCommandAction({
9495
icon: 'terminal-bash',
9596
label: 'Open in External Terminal',
@@ -100,6 +101,14 @@ class WorktreeActionPicker {
100101
label: 'Open in Built-in Terminal',
101102
action: Commands.openTerminal,
102103
}),
104+
separator,
105+
this.buildCommandAction({ icon: 'history', label: 'View Git history', action: Commands.viewHistory }),
106+
this.buildCommandAction({
107+
icon: 'repo',
108+
label: 'Open the repository in Source Control view',
109+
action: Commands.openRepository,
110+
}),
111+
separator,
103112
this.buildCommandAction({
104113
icon: 'multiple-windows',
105114
label: 'Add Folder to Workspace',
@@ -117,10 +126,11 @@ class WorktreeActionPicker {
117126
label: 'Reveal in System Explorer',
118127
action: Commands.revealInSystemExplorerContext,
119128
}),
129+
separator,
120130
this.buildCommandAction({
121-
icon: 'repo',
122-
label: 'Open the repository in Source Control view',
123-
action: Commands.openRepository,
131+
icon: 'move',
132+
label: 'Move Worktree',
133+
action: Commands.moveWorktree,
124134
}),
125135
this.buildCommandAction({
126136
icon: 'trash',
@@ -169,20 +179,23 @@ class WorktreeActionPicker {
169179
case 'copy':
170180
await this.handleCopyAction(item.description || '');
171181
break;
182+
case Commands.moveWorktree:
172183
case Commands.openExternalTerminalContext:
173184
case Commands.openTerminal:
174185
case Commands.revealInSystemExplorerContext:
175186
case Commands.viewHistory:
176187
case Commands.openRepository:
177-
case Commands.removeWorktree:
178-
await this.handleCommandAction(item.action, viewItem);
179-
break;
188+
case Commands.removeWorktree:
189+
await this.handleCommandAction(item.action, viewItem);
190+
break;
180191
case Commands.removeFromWorkspace:
181192
case Commands.addToWorkspace:
182193
reject();
183194
quickPick.hide();
184195
this.handleWorkspaceAction(item.action, viewItem);
185196
return;
197+
case 'separator':
198+
break;
186199
default:
187200
const value: never = item.action;
188201
void value;

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export enum GitHistoryExtension {
138138

139139
export interface QuickPickAction extends vscode.QuickPickItem {
140140
action:
141+
| 'separator'
141142
| 'copy'
142143
| Commands.openTerminal
143144
| Commands.openExternalTerminalContext
@@ -146,6 +147,7 @@ export interface QuickPickAction extends vscode.QuickPickItem {
146147
| Commands.removeFromWorkspace
147148
| Commands.viewHistory
148149
| Commands.openRepository
150+
| Commands.moveWorktree
149151
| Commands.removeWorktree;
150152
hide?: boolean;
151153
}

0 commit comments

Comments
 (0)