Skip to content

Commit 5407ab6

Browse files
committed
Share context key in terminal
Context: microsoft@8fdc754
1 parent b637950 commit 5407ab6

File tree

2 files changed

+29
-47
lines changed

2 files changed

+29
-47
lines changed

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

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -426,29 +426,7 @@ export function setupTerminalMenus(): void {
426426
},
427427
group: 'navigation',
428428
order: 2,
429-
when: ContextKeyExpr.and(
430-
ContextKeyExpr.equals('view', TERMINAL_VIEW_ID),
431-
ContextKeyExpr.notEquals(`config.${TerminalSettingId.TabsHideCondition}`, 'never'),
432-
ContextKeyExpr.or(
433-
ContextKeyExpr.not(`config.${TerminalSettingId.TabsEnabled}`),
434-
ContextKeyExpr.and(
435-
ContextKeyExpr.equals(`config.${TerminalSettingId.TabsShowActions}`, 'singleTerminal'),
436-
ContextKeyExpr.equals(TerminalContextKeyStrings.GroupCount, 1)
437-
),
438-
ContextKeyExpr.and(
439-
ContextKeyExpr.equals(`config.${TerminalSettingId.TabsShowActions}`, 'singleTerminalOrNarrow'),
440-
ContextKeyExpr.or(
441-
ContextKeyExpr.equals(TerminalContextKeyStrings.GroupCount, 1),
442-
ContextKeyExpr.has(TerminalContextKeyStrings.TabsNarrow)
443-
)
444-
),
445-
ContextKeyExpr.and(
446-
ContextKeyExpr.equals(`config.${TerminalSettingId.TabsShowActions}`, 'singleGroup'),
447-
ContextKeyExpr.equals(TerminalContextKeyStrings.GroupCount, 1)
448-
),
449-
ContextKeyExpr.equals(`config.${TerminalSettingId.TabsShowActions}`, 'always')
450-
)
451-
)
429+
when: TerminalContextKeys.shouldShowViewInlineActions
452430
}
453431
},
454432
{
@@ -461,29 +439,7 @@ export function setupTerminalMenus(): void {
461439
},
462440
group: 'navigation',
463441
order: 3,
464-
when: ContextKeyExpr.and(
465-
ContextKeyExpr.equals('view', TERMINAL_VIEW_ID),
466-
ContextKeyExpr.notEquals(`config.${TerminalSettingId.TabsHideCondition}`, 'never'),
467-
ContextKeyExpr.or(
468-
ContextKeyExpr.not(`config.${TerminalSettingId.TabsEnabled}`),
469-
ContextKeyExpr.and(
470-
ContextKeyExpr.equals(`config.${TerminalSettingId.TabsShowActions}`, 'singleTerminal'),
471-
ContextKeyExpr.equals(TerminalContextKeyStrings.GroupCount, 1)
472-
),
473-
ContextKeyExpr.and(
474-
ContextKeyExpr.equals(`config.${TerminalSettingId.TabsShowActions}`, 'singleTerminalOrNarrow'),
475-
ContextKeyExpr.or(
476-
ContextKeyExpr.equals(TerminalContextKeyStrings.GroupCount, 1),
477-
ContextKeyExpr.has(TerminalContextKeyStrings.TabsNarrow)
478-
)
479-
),
480-
ContextKeyExpr.and(
481-
ContextKeyExpr.equals(`config.${TerminalSettingId.TabsShowActions}`, 'singleGroup'),
482-
ContextKeyExpr.equals(TerminalContextKeyStrings.GroupCount, 1)
483-
),
484-
ContextKeyExpr.equals(`config.${TerminalSettingId.TabsShowActions}`, 'always')
485-
)
486-
)
442+
when: TerminalContextKeys.shouldShowViewInlineActions
487443
}
488444
},
489445
{

src/vs/workbench/contrib/terminal/common/terminalContextKey.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { localize } from 'vs/nls';
7-
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
7+
import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
8+
import { TerminalSettingId } from 'vs/platform/terminal/common/terminal';
9+
import { TERMINAL_VIEW_ID } from 'vs/workbench/contrib/terminal/common/terminal';
810

911
export const enum TerminalContextKeyStrings {
1012
IsOpen = 'terminalIsOpen',
@@ -132,4 +134,28 @@ export namespace TerminalContextKeys {
132134

133135
/** Whether shell integration is enabled in the active terminal. This only considers full VS Code shell integration. */
134136
export const terminalShellIntegrationEnabled = new RawContextKey<boolean>(TerminalContextKeyStrings.TerminalShellIntegrationEnabled, false, localize('terminalShellIntegrationEnabled', "Whether shell integration is enabled in the active terminal"));
137+
138+
export const shouldShowViewInlineActions = ContextKeyExpr.and(
139+
ContextKeyExpr.equals('view', TERMINAL_VIEW_ID),
140+
ContextKeyExpr.notEquals(`config.${TerminalSettingId.TabsHideCondition}`, 'never'),
141+
ContextKeyExpr.or(
142+
ContextKeyExpr.not(`config.${TerminalSettingId.TabsEnabled}`),
143+
ContextKeyExpr.and(
144+
ContextKeyExpr.equals(`config.${TerminalSettingId.TabsShowActions}`, 'singleTerminal'),
145+
ContextKeyExpr.equals(TerminalContextKeyStrings.GroupCount, 1)
146+
),
147+
ContextKeyExpr.and(
148+
ContextKeyExpr.equals(`config.${TerminalSettingId.TabsShowActions}`, 'singleTerminalOrNarrow'),
149+
ContextKeyExpr.or(
150+
ContextKeyExpr.equals(TerminalContextKeyStrings.GroupCount, 1),
151+
ContextKeyExpr.has(TerminalContextKeyStrings.TabsNarrow)
152+
)
153+
),
154+
ContextKeyExpr.and(
155+
ContextKeyExpr.equals(`config.${TerminalSettingId.TabsShowActions}`, 'singleGroup'),
156+
ContextKeyExpr.equals(TerminalContextKeyStrings.GroupCount, 1)
157+
),
158+
ContextKeyExpr.equals(`config.${TerminalSettingId.TabsShowActions}`, 'always')
159+
)
160+
);
135161
}

0 commit comments

Comments
 (0)