Move command ids into terminalContrib

This commit is contained in:
Daniel Imms
2024-10-01 07:21:24 -07:00
parent c5e693c011
commit b90c602bb2
5 changed files with 59 additions and 47 deletions

View File

@@ -396,11 +396,9 @@ export const enum TerminalCommandId {
QuickKill = 'workbench.action.terminal.quickKill',
ConfigureTerminalSettings = 'workbench.action.terminal.openSettings',
ShellIntegrationLearnMore = 'workbench.action.terminal.learnMore',
RunRecentCommand = 'workbench.action.terminal.runRecentCommand',
CopyLastCommand = 'workbench.action.terminal.copyLastCommand',
CopyLastCommandOutput = 'workbench.action.terminal.copyLastCommandOutput',
CopyLastCommandAndLastCommandOutput = 'workbench.action.terminal.copyLastCommandAndLastCommandOutput',
GoToRecentDirectory = 'workbench.action.terminal.goToRecentDirectory',
CopyAndClearSelection = 'workbench.action.terminal.copyAndClearSelection',
CopySelection = 'workbench.action.terminal.copySelection',
CopySelectionAsHtml = 'workbench.action.terminal.copySelectionAsHtml',
@@ -471,7 +469,6 @@ export const enum TerminalCommandId {
MoveToTerminalPanel = 'workbench.action.terminal.moveToTerminalPanel',
MoveIntoNewWindow = 'workbench.action.terminal.moveIntoNewWindow',
SetDimensions = 'workbench.action.terminal.setDimensions',
ClearPreviousSessionHistory = 'workbench.action.terminal.clearPreviousSessionHistory',
FocusHover = 'workbench.action.terminal.focusHover',
ShowEnvironmentContributions = 'workbench.action.terminal.showEnvironmentContributions',
StartVoice = 'workbench.action.terminal.startVoice',
@@ -490,7 +487,6 @@ export const DEFAULT_COMMANDS_TO_SKIP_SHELL: string[] = [
TerminalCommandId.DeleteToLineStart,
TerminalCommandId.DeleteWordLeft,
TerminalCommandId.DeleteWordRight,
TerminalCommandId.GoToRecentDirectory,
TerminalCommandId.FocusNextPane,
TerminalCommandId.FocusNext,
TerminalCommandId.FocusPreviousPane,
@@ -513,7 +509,6 @@ export const DEFAULT_COMMANDS_TO_SKIP_SHELL: string[] = [
TerminalCommandId.ResizePaneUp,
TerminalCommandId.RunActiveFile,
TerminalCommandId.RunSelectedText,
TerminalCommandId.RunRecentCommand,
TerminalCommandId.ScrollDownLine,
TerminalCommandId.ScrollDownPage,
TerminalCommandId.ScrollToBottom,

View File

@@ -11,6 +11,7 @@ import { terminalInitialHintConfiguration } from '../terminalContrib/chat/common
import { terminalCommandGuideConfiguration } from '../terminalContrib/commandGuide/common/terminalCommandGuideConfiguration.js';
import { TerminalDeveloperCommandId } from '../terminalContrib/developer/common/terminal.developer.js';
import { defaultTerminalFindCommandToSkipShell } from '../terminalContrib/find/common/terminal.find.js';
import { defaultTerminalHistoryCommandsToSkipShell } from '../terminalContrib/history/common/terminal.history.js';
import { TerminalStickyScrollSettingId, terminalStickyScrollConfiguration } from '../terminalContrib/stickyScroll/common/terminalStickyScrollConfiguration.js';
import { defaultTerminalSuggestCommandsToSkipShell } from '../terminalContrib/suggest/common/terminal.suggest.js';
import { TerminalSuggestSettingId, terminalSuggestConfiguration } from '../terminalContrib/suggest/common/terminalSuggestConfiguration.js';
@@ -51,5 +52,6 @@ export const terminalContribConfiguration: IConfigurationNode['properties'] = {
export const defaultTerminalContribCommandsToSkipShell = [
...defaultTerminalAccessibilityCommandsToSkipShell,
...defaultTerminalFindCommandToSkipShell,
...defaultTerminalHistoryCommandsToSkipShell,
...defaultTerminalSuggestCommandsToSkipShell,
];

View File

@@ -19,6 +19,7 @@ import { TerminalAccessibilityCommandId } from '../common/terminal.accessibility
import { TerminalLinksCommandId } from '../../links/common/terminal.links.js';
import { IAccessibleViewContentProvider, AccessibleViewProviderId, IAccessibleViewOptions, AccessibleViewType } from '../../../../../platform/accessibility/browser/accessibleView.js';
import { accessibleViewIsShown, accessibleViewCurrentProviderId, AccessibilityVerbositySettingId } from '../../../accessibility/browser/accessibilityConfiguration.js';
import { TerminalHistoryCommandId } from '../../history/common/terminal.history.js';
export const enum ClassName {
Active = 'active',
@@ -76,8 +77,8 @@ export class TerminalAccessibilityHelpProvider extends Disposable implements IAc
content.push('- ' + localize('goToNextCommand', 'Go to Next Command<keybinding:{0}> in the accessible view', TerminalAccessibilityCommandId.AccessibleBufferGoToNextCommand));
content.push('- ' + localize('goToPreviousCommand', 'Go to Previous Command<keybinding:{0}> in the accessible view', TerminalAccessibilityCommandId.AccessibleBufferGoToPreviousCommand));
content.push('- ' + localize('goToSymbol', 'Go to Symbol<keybinding:{0}>', AccessibilityCommandId.GoToSymbol));
content.push('- ' + localize('runRecentCommand', 'Run Recent Command<keybinding:{0}>', TerminalCommandId.RunRecentCommand));
content.push('- ' + localize('goToRecentDirectory', 'Go to Recent Directory<keybinding:{0}>', TerminalCommandId.GoToRecentDirectory));
content.push('- ' + localize('runRecentCommand', 'Run Recent Command<keybinding:{0}>', TerminalHistoryCommandId.RunRecentCommand));
content.push('- ' + localize('goToRecentDirectory', 'Go to Recent Directory<keybinding:{0}>', TerminalHistoryCommandId.GoToRecentDirectory));
} else {
content.push(localize('noShellIntegration', 'Shell integration is not enabled. Some accessibility features may not be available.'));
}

View File

@@ -18,9 +18,10 @@ import type { ITerminalContribution, ITerminalInstance } from '../../../terminal
import { registerActiveInstanceAction, registerTerminalAction } from '../../../terminal/browser/terminalActions.js';
import { registerTerminalContribution } from '../../../terminal/browser/terminalExtensions.js';
import type { TerminalWidgetManager } from '../../../terminal/browser/widgets/widgetManager.js';
import { TerminalCommandId, type ITerminalProcessManager } from '../../../terminal/common/terminal.js';
import { type ITerminalProcessManager } from '../../../terminal/common/terminal.js';
import { TerminalContextKeys } from '../../../terminal/common/terminalContextKey.js';
import { clearShellFileHistory, getCommandHistory, getDirectoryHistory } from '../common/history.js';
import { TerminalHistoryCommandId } from '../common/terminal.history.js';
import { showRunRecentQuickPick } from './terminalRunRecentQuickPick.js';
// #region Terminal Contributions
@@ -88,8 +89,44 @@ registerTerminalContribution(TerminalHistoryContribution.ID, TerminalHistoryCont
const precondition = ContextKeyExpr.or(TerminalContextKeys.processSupported, TerminalContextKeys.terminalHasBeenCreated);
registerTerminalAction({
id: TerminalHistoryCommandId.ClearPreviousSessionHistory,
title: localize2('workbench.action.terminal.clearPreviousSessionHistory', 'Clear Previous Session History'),
precondition,
run: async (c, accessor) => {
getCommandHistory(accessor).clear();
clearShellFileHistory();
}
});
registerActiveInstanceAction({
id: TerminalCommandId.RunRecentCommand,
id: TerminalHistoryCommandId.GoToRecentDirectory,
title: localize2('workbench.action.terminal.goToRecentDirectory', 'Go to Recent Directory...'),
metadata: {
description: localize2('goToRecentDirectory.metadata', 'Goes to a recent folder'),
},
precondition,
keybinding: {
primary: KeyMod.CtrlCmd | KeyCode.KeyG,
when: TerminalContextKeys.focus,
weight: KeybindingWeight.WorkbenchContrib
},
run: async (activeInstance, c) => {
const history = TerminalHistoryContribution.get(activeInstance);
if (!history) {
return;
}
await history.runRecent('cwd');
if (activeInstance?.target === TerminalLocation.Editor) {
await c.editorService.revealActiveEditor();
} else {
await c.groupService.showPanel(false);
}
}
});
registerActiveInstanceAction({
id: TerminalHistoryCommandId.RunRecentCommand,
title: localize2('workbench.action.terminal.runRecentCommand', 'Run Recent Command...'),
precondition,
keybinding: [
@@ -119,42 +156,4 @@ registerActiveInstanceAction({
}
});
// TODO: move command IDs into this file
registerActiveInstanceAction({
id: TerminalCommandId.GoToRecentDirectory,
title: localize2('workbench.action.terminal.goToRecentDirectory', 'Go to Recent Directory...'),
metadata: {
description: localize2('goToRecentDirectory.metadata', 'Goes to a recent folder'),
},
precondition,
keybinding: {
primary: KeyMod.CtrlCmd | KeyCode.KeyG,
when: TerminalContextKeys.focus,
weight: KeybindingWeight.WorkbenchContrib
},
run: async (activeInstance, c) => {
const history = TerminalHistoryContribution.get(activeInstance);
if (!history) {
return;
}
await history.runRecent('cwd');
if (activeInstance?.target === TerminalLocation.Editor) {
await c.editorService.revealActiveEditor();
} else {
await c.groupService.showPanel(false);
}
}
});
registerTerminalAction({
id: TerminalCommandId.ClearPreviousSessionHistory,
title: localize2('workbench.action.terminal.clearPreviousSessionHistory', 'Clear Previous Session History'),
precondition,
run: async (c, accessor) => {
getCommandHistory(accessor).clear();
clearShellFileHistory();
}
});
// #endregion

View File

@@ -0,0 +1,15 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export const enum TerminalHistoryCommandId {
ClearPreviousSessionHistory = 'workbench.action.terminal.clearPreviousSessionHistory',
GoToRecentDirectory = 'workbench.action.terminal.goToRecentDirectory',
RunRecentCommand = 'workbench.action.terminal.runRecentCommand',
}
export const defaultTerminalHistoryCommandsToSkipShell = [
TerminalHistoryCommandId.GoToRecentDirectory,
TerminalHistoryCommandId.RunRecentCommand
];