Skip to content

Commit 04b5641

Browse files
authored
Merge pull request microsoft#261044 from microsoft/tyriar/259260
Move terminal selection/command tools to core
2 parents c146989 + 68189b8 commit 04b5641

File tree

10 files changed

+293
-68
lines changed

10 files changed

+293
-68
lines changed

src/vs/platform/actions/common/actions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ export class MenuId {
253253
static readonly ChatAttachmentsContext = new MenuId('ChatAttachmentsContext');
254254
static readonly ChatToolOutputResourceToolbar = new MenuId('ChatToolOutputResourceToolbar');
255255
static readonly ChatTextEditorMenu = new MenuId('ChatTextEditorMenu');
256-
static readonly ChatTerminalMenu = new MenuId('ChatTerminalMenu');
257256
static readonly ChatToolOutputResourceContext = new MenuId('ChatToolOutputResourceContext');
258257
static readonly ChatSessionsMenu = new MenuId('ChatSessionsMenu');
259258
static readonly ChatConfirmationMenu = new MenuId('ChatConfirmationMenu');

src/vs/workbench/contrib/chat/browser/actions/chatActions.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,13 +1488,6 @@ MenuRegistry.appendMenuItem(MenuId.EditorContext, {
14881488
when: menuContext
14891489
});
14901490

1491-
MenuRegistry.appendMenuItem(MenuId.TerminalInstanceContext, {
1492-
submenu: MenuId.ChatTerminalMenu,
1493-
group: '2_copilot',
1494-
title,
1495-
when: menuContext
1496-
});
1497-
14981491
// --- Chat Default Visibility
14991492

15001493
registerAction2(class ToggleDefaultVisibilityAction extends Action2 {

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
454454

455455
this._terminalFocusContextKey = TerminalContextKeys.focus.bindTo(scopedContextKeyService);
456456
this._terminalHasFixedWidth = TerminalContextKeys.terminalHasFixedWidth.bindTo(scopedContextKeyService);
457-
this._terminalHasTextContextKey = TerminalContextKeys.textSelected.bindTo(scopedContextKeyService);
457+
this._terminalHasTextContextKey = TerminalContextKeys.textSelected.bindTo(this._contextKeyService);
458458
this._terminalAltBufferActiveContextKey = TerminalContextKeys.altBufferActive.bindTo(scopedContextKeyService);
459459
this._terminalShellIntegrationEnabledContextKey = TerminalContextKeys.terminalShellIntegrationEnabled.bindTo(scopedContextKeyService);
460460

src/vs/workbench/contrib/terminal/browser/terminalMenus.ts

Lines changed: 30 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import { terminalStrings } from '../common/terminalStrings.js';
1919
import { ACTIVE_GROUP, AUX_WINDOW_GROUP, SIDE_GROUP } from '../../../services/editor/common/editorService.js';
2020
import { DisposableStore } from '../../../../base/common/lifecycle.js';
2121

22-
const enum ContextMenuGroup {
22+
export const enum TerminalContextMenuGroup {
23+
Chat = '0_chat',
2324
Create = '1_create',
2425
Edit = '3_edit',
2526
Clear = '5_clear',
@@ -103,34 +104,14 @@ export function setupTerminalMenus(): void {
103104

104105
MenuRegistry.appendMenuItems(
105106
[
106-
{
107-
id: MenuId.TerminalInstanceContext,
108-
item: {
109-
group: ContextMenuGroup.Create,
110-
command: {
111-
id: TerminalCommandId.Split,
112-
title: terminalStrings.split.value
113-
}
114-
}
115-
},
116-
{
117-
id: MenuId.TerminalInstanceContext,
118-
item: {
119-
command: {
120-
id: TerminalCommandId.New,
121-
title: terminalStrings.new
122-
},
123-
group: ContextMenuGroup.Create
124-
}
125-
},
126107
{
127108
id: MenuId.TerminalInstanceContext,
128109
item: {
129110
command: {
130111
id: TerminalCommandId.KillViewOrEditor,
131112
title: terminalStrings.kill.value,
132113
},
133-
group: ContextMenuGroup.Kill
114+
group: TerminalContextMenuGroup.Kill
134115
}
135116
},
136117
{
@@ -140,7 +121,7 @@ export function setupTerminalMenus(): void {
140121
id: TerminalCommandId.CopySelection,
141122
title: localize('workbench.action.terminal.copySelection.short', "Copy")
142123
},
143-
group: ContextMenuGroup.Edit,
124+
group: TerminalContextMenuGroup.Edit,
144125
order: 1
145126
}
146127
},
@@ -151,7 +132,7 @@ export function setupTerminalMenus(): void {
151132
id: TerminalCommandId.CopySelectionAsHtml,
152133
title: localize('workbench.action.terminal.copySelectionAsHtml', "Copy as HTML")
153134
},
154-
group: ContextMenuGroup.Edit,
135+
group: TerminalContextMenuGroup.Edit,
155136
order: 2
156137
}
157138
},
@@ -162,7 +143,7 @@ export function setupTerminalMenus(): void {
162143
id: TerminalCommandId.Paste,
163144
title: localize('workbench.action.terminal.paste.short', "Paste")
164145
},
165-
group: ContextMenuGroup.Edit,
146+
group: TerminalContextMenuGroup.Edit,
166147
order: 3
167148
}
168149
},
@@ -173,7 +154,7 @@ export function setupTerminalMenus(): void {
173154
id: TerminalCommandId.Clear,
174155
title: localize('workbench.action.terminal.clear', "Clear")
175156
},
176-
group: ContextMenuGroup.Clear,
157+
group: TerminalContextMenuGroup.Clear,
177158
}
178159
},
179160
{
@@ -183,7 +164,7 @@ export function setupTerminalMenus(): void {
183164
id: TerminalCommandId.SizeToContentWidth,
184165
title: terminalStrings.toggleSizeToContentWidth
185166
},
186-
group: ContextMenuGroup.Config
167+
group: TerminalContextMenuGroup.Config
187168
}
188169
},
189170

@@ -194,7 +175,7 @@ export function setupTerminalMenus(): void {
194175
id: TerminalCommandId.SelectAll,
195176
title: localize('workbench.action.terminal.selectAll', "Select All"),
196177
},
197-
group: ContextMenuGroup.Edit,
178+
group: TerminalContextMenuGroup.Edit,
198179
order: 3
199180
}
200181
},
@@ -226,7 +207,7 @@ export function setupTerminalMenus(): void {
226207
{
227208
id: MenuId.TerminalEditorInstanceContext,
228209
item: {
229-
group: ContextMenuGroup.Create,
210+
group: TerminalContextMenuGroup.Create,
230211
command: {
231212
id: TerminalCommandId.Split,
232213
title: terminalStrings.split.value
@@ -240,7 +221,7 @@ export function setupTerminalMenus(): void {
240221
id: TerminalCommandId.New,
241222
title: terminalStrings.new
242223
},
243-
group: ContextMenuGroup.Create
224+
group: TerminalContextMenuGroup.Create
244225
}
245226
},
246227
{
@@ -250,7 +231,7 @@ export function setupTerminalMenus(): void {
250231
id: TerminalCommandId.KillEditor,
251232
title: terminalStrings.kill.value
252233
},
253-
group: ContextMenuGroup.Kill
234+
group: TerminalContextMenuGroup.Kill
254235
}
255236
},
256237
{
@@ -260,7 +241,7 @@ export function setupTerminalMenus(): void {
260241
id: TerminalCommandId.CopySelection,
261242
title: localize('workbench.action.terminal.copySelection.short', "Copy")
262243
},
263-
group: ContextMenuGroup.Edit,
244+
group: TerminalContextMenuGroup.Edit,
264245
order: 1
265246
}
266247
},
@@ -271,7 +252,7 @@ export function setupTerminalMenus(): void {
271252
id: TerminalCommandId.CopySelectionAsHtml,
272253
title: localize('workbench.action.terminal.copySelectionAsHtml', "Copy as HTML")
273254
},
274-
group: ContextMenuGroup.Edit,
255+
group: TerminalContextMenuGroup.Edit,
275256
order: 2
276257
}
277258
},
@@ -282,7 +263,7 @@ export function setupTerminalMenus(): void {
282263
id: TerminalCommandId.Paste,
283264
title: localize('workbench.action.terminal.paste.short', "Paste")
284265
},
285-
group: ContextMenuGroup.Edit,
266+
group: TerminalContextMenuGroup.Edit,
286267
order: 3
287268
}
288269
},
@@ -293,7 +274,7 @@ export function setupTerminalMenus(): void {
293274
id: TerminalCommandId.Clear,
294275
title: localize('workbench.action.terminal.clear', "Clear")
295276
},
296-
group: ContextMenuGroup.Clear,
277+
group: TerminalContextMenuGroup.Clear,
297278
}
298279
},
299280
{
@@ -303,7 +284,7 @@ export function setupTerminalMenus(): void {
303284
id: TerminalCommandId.SelectAll,
304285
title: localize('workbench.action.terminal.selectAll', "Select All"),
305286
},
306-
group: ContextMenuGroup.Edit,
287+
group: TerminalContextMenuGroup.Edit,
307288
order: 3
308289
}
309290
},
@@ -314,7 +295,7 @@ export function setupTerminalMenus(): void {
314295
id: TerminalCommandId.SizeToContentWidth,
315296
title: terminalStrings.toggleSizeToContentWidth
316297
},
317-
group: ContextMenuGroup.Config
298+
group: TerminalContextMenuGroup.Config
318299
}
319300
}
320301
]
@@ -329,7 +310,7 @@ export function setupTerminalMenus(): void {
329310
id: TerminalCommandId.NewWithProfile,
330311
title: localize('workbench.action.terminal.newWithProfile.short', "New Terminal With Profile...")
331312
},
332-
group: ContextMenuGroup.Create
313+
group: TerminalContextMenuGroup.Create
333314
}
334315
},
335316
{
@@ -339,7 +320,7 @@ export function setupTerminalMenus(): void {
339320
id: TerminalCommandId.New,
340321
title: terminalStrings.new
341322
},
342-
group: ContextMenuGroup.Create
323+
group: TerminalContextMenuGroup.Create
343324
}
344325
}
345326
]
@@ -551,7 +532,7 @@ export function setupTerminalMenus(): void {
551532
id: TerminalCommandId.SplitActiveTab,
552533
title: terminalStrings.split.value,
553534
},
554-
group: ContextMenuGroup.Create,
535+
group: TerminalContextMenuGroup.Create,
555536
order: 1
556537
}
557538
},
@@ -562,7 +543,7 @@ export function setupTerminalMenus(): void {
562543
id: TerminalCommandId.MoveToEditor,
563544
title: terminalStrings.moveToEditor.value
564545
},
565-
group: ContextMenuGroup.Create,
546+
group: TerminalContextMenuGroup.Create,
566547
order: 2
567548
}
568549
},
@@ -573,7 +554,7 @@ export function setupTerminalMenus(): void {
573554
id: TerminalCommandId.MoveIntoNewWindow,
574555
title: terminalStrings.moveIntoNewWindow.value
575556
},
576-
group: ContextMenuGroup.Create,
557+
group: TerminalContextMenuGroup.Create,
577558
order: 2
578559
}
579560
},
@@ -584,7 +565,7 @@ export function setupTerminalMenus(): void {
584565
id: TerminalCommandId.RenameActiveTab,
585566
title: localize('workbench.action.terminal.renameInstance', "Rename...")
586567
},
587-
group: ContextMenuGroup.Edit
568+
group: TerminalContextMenuGroup.Edit
588569
}
589570
},
590571
{
@@ -594,7 +575,7 @@ export function setupTerminalMenus(): void {
594575
id: TerminalCommandId.ChangeIconActiveTab,
595576
title: localize('workbench.action.terminal.changeIcon', "Change Icon...")
596577
},
597-
group: ContextMenuGroup.Edit
578+
group: TerminalContextMenuGroup.Edit
598579
}
599580
},
600581
{
@@ -604,7 +585,7 @@ export function setupTerminalMenus(): void {
604585
id: TerminalCommandId.ChangeColorActiveTab,
605586
title: localize('workbench.action.terminal.changeColor', "Change Color...")
606587
},
607-
group: ContextMenuGroup.Edit
588+
group: TerminalContextMenuGroup.Edit
608589
}
609590
},
610591
{
@@ -614,7 +595,7 @@ export function setupTerminalMenus(): void {
614595
id: TerminalCommandId.SizeToContentWidth,
615596
title: terminalStrings.toggleSizeToContentWidth
616597
},
617-
group: ContextMenuGroup.Edit
598+
group: TerminalContextMenuGroup.Edit
618599
}
619600
},
620601
{
@@ -625,7 +606,7 @@ export function setupTerminalMenus(): void {
625606
title: localize('workbench.action.terminal.joinInstance', "Join Terminals")
626607
},
627608
when: TerminalContextKeys.tabsSingularSelection.toNegated(),
628-
group: ContextMenuGroup.Config
609+
group: TerminalContextMenuGroup.Config
629610
}
630611
},
631612
{
@@ -636,7 +617,7 @@ export function setupTerminalMenus(): void {
636617
title: terminalStrings.unsplit.value
637618
},
638619
when: ContextKeyExpr.and(TerminalContextKeys.tabsSingularSelection, TerminalContextKeys.splitTerminalTabFocused),
639-
group: ContextMenuGroup.Config
620+
group: TerminalContextMenuGroup.Config
640621
}
641622
},
642623
{
@@ -646,7 +627,7 @@ export function setupTerminalMenus(): void {
646627
id: TerminalCommandId.KillActiveTab,
647628
title: terminalStrings.kill.value
648629
},
649-
group: ContextMenuGroup.Kill,
630+
group: TerminalContextMenuGroup.Kill,
650631
}
651632
}
652633
]

src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ChatAgentLocation } from '../../../chat/common/constants.js';
1616
import { AbstractInline1ChatAction } from '../../../inlineChat/browser/inlineChatActions.js';
1717
import { isDetachedTerminalInstance } from '../../../terminal/browser/terminal.js';
1818
import { registerActiveXtermAction } from '../../../terminal/browser/terminalActions.js';
19+
import { TerminalContextMenuGroup } from '../../../terminal/browser/terminalMenus.js';
1920
import { TerminalContextKeys } from '../../../terminal/common/terminalContextKey.js';
2021
import { MENU_TERMINAL_CHAT_WIDGET_STATUS, TerminalChatCommandId, TerminalChatContextKeys } from './terminalChat.js';
2122
import { TerminalChatController } from './terminalChatController.js';
@@ -37,9 +38,9 @@ registerActiveXtermAction({
3738
TerminalChatContextKeys.hasChatAgent
3839
),
3940
menu: {
40-
id: MenuId.ChatTerminalMenu,
41-
group: 'copilot',
42-
order: 1
41+
id: MenuId.TerminalInstanceContext,
42+
group: TerminalContextMenuGroup.Chat,
43+
order: 2
4344
},
4445
run: (_xterm, _accessor, activeInstance, opts?: unknown) => {
4546
if (isDetachedTerminalInstance(activeInstance)) {

0 commit comments

Comments
 (0)