diff --git a/src/vs/workbench/contrib/terminal/browser/terminal.contribution.ts b/src/vs/workbench/contrib/terminal/browser/terminal.contribution.ts index 0c101e2a431..25a2010e1c9 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminal.contribution.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminal.contribution.ts @@ -10,7 +10,7 @@ import 'vs/css!./media/terminal'; import 'vs/css!./media/widgets'; import 'vs/css!./media/xterm'; import * as nls from 'vs/nls'; -import { SyncActionDescriptor, registerAction2 } from 'vs/platform/actions/common/actions'; +import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { ContextKeyExpr, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey'; import { KeybindingWeight, KeybindingsRegistry, IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry'; @@ -19,35 +19,29 @@ import * as panel from 'vs/workbench/browser/panel'; import { getQuickNavigateHandler } from 'vs/workbench/browser/quickaccess'; import { Extensions as ActionExtensions, IWorkbenchActionRegistry } from 'vs/workbench/common/actions'; import { Extensions as ViewContainerExtensions, IViewContainersRegistry, ViewContainerLocation, IViewsRegistry } from 'vs/workbench/common/views'; -import { ClearSelectionTerminalAction, ClearTerminalAction, CopyTerminalSelectionAction, CreateNewInActiveWorkspaceTerminalAction, CreateNewTerminalAction, FindNext, FindPrevious, FocusActiveTerminalAction, FocusNextPaneTerminalAction, FocusNextTerminalAction, FocusPreviousPaneTerminalAction, FocusPreviousTerminalAction, FocusTerminalFindWidgetAction, HideTerminalFindWidgetAction, KillTerminalAction, QuickAccessTerminalAction, RenameTerminalAction, ResizePaneDownTerminalAction, ResizePaneLeftTerminalAction, ResizePaneRightTerminalAction, ResizePaneUpTerminalAction, RunActiveFileInTerminalAction, RunSelectedTextInTerminalAction, ScrollDownPageTerminalAction, ScrollDownTerminalAction, ScrollToBottomTerminalAction, ScrollToNextCommandAction, ScrollToPreviousCommandAction, ScrollToTopTerminalAction, ScrollUpPageTerminalAction, ScrollUpTerminalAction, SelectAllTerminalAction, SelectDefaultShellWindowsTerminalAction, SelectToNextCommandAction, SelectToNextLineAction, SelectToPreviousCommandAction, SelectToPreviousLineAction, SplitInActiveWorkspaceTerminalAction, SplitTerminalAction, TerminalPasteAction, ToggleCaseSensitiveCommand, ToggleEscapeSequenceLoggingAction, ToggleRegexCommand, ToggleTerminalAction, ToggleWholeWordCommand, NavigationModeFocusPreviousTerminalAction, NavigationModeFocusNextTerminalAction, NavigationModeExitTerminalAction, ManageWorkspaceShellPermissionsTerminalCommand, CreateNewWithCwdTerminalAction, RenameWithArgTerminalAction, SendSequenceTerminalAction, terminalSendSequenceCommand } from 'vs/workbench/contrib/terminal/browser/terminalActions'; +import { registerTerminalActions, ClearTerminalAction, CopyTerminalSelectionAction, CreateNewTerminalAction, KillTerminalAction, SelectAllTerminalAction, SelectDefaultShellWindowsTerminalAction, SplitInActiveWorkspaceTerminalAction, SplitTerminalAction, TerminalPasteAction, ToggleTerminalAction, terminalSendSequenceCommand } from 'vs/workbench/contrib/terminal/browser/terminalActions'; import { TerminalViewPane } from 'vs/workbench/contrib/terminal/browser/terminalView'; -import { KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_NOT_VISIBLE, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE, KEYBINDING_CONTEXT_TERMINAL_SHELL_TYPE_KEY, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, TERMINAL_VIEW_ID, DEFAULT_LETTER_SPACING, DEFAULT_LINE_HEIGHT, TerminalCursorStyle, TERMINAL_ACTION_CATEGORY, KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, TERMINAL_COMMAND_ID } from 'vs/workbench/contrib/terminal/common/terminal'; +import { KEYBINDING_CONTEXT_TERMINAL_SHELL_TYPE_KEY, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, TERMINAL_VIEW_ID, TERMINAL_ACTION_CATEGORY, TERMINAL_COMMAND_ID } from 'vs/workbench/contrib/terminal/common/terminal'; import { registerColors } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry'; import { setupTerminalCommands } from 'vs/workbench/contrib/terminal/browser/terminalCommands'; import { setupTerminalMenu } from 'vs/workbench/contrib/terminal/common/terminalMenu'; import { IConfigurationRegistry, Extensions } from 'vs/platform/configuration/common/configurationRegistry'; -import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions'; -import { DEFAULT_COMMANDS_TO_SKIP_SHELL } from 'vs/workbench/contrib/terminal/browser/terminalInstance'; import { TerminalService } from 'vs/workbench/contrib/terminal/browser/terminalService'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; -import { registerShellConfiguration } from 'vs/workbench/contrib/terminal/common/terminalShellConfig'; -import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vs/platform/accessibility/common/accessibility'; import { ITerminalService, WindowsShellType } from 'vs/workbench/contrib/terminal/browser/terminal'; import { BrowserFeatures } from 'vs/base/browser/canIUse'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { ViewPaneContainer } from 'vs/workbench/browser/parts/views/viewPaneContainer'; import { IQuickAccessRegistry, Extensions as QuickAccessExtensions } from 'vs/platform/quickinput/common/quickAccess'; import { TerminalQuickAccessProvider } from 'vs/workbench/contrib/terminal/browser/terminalsQuickAccess'; +import { terminalConfiguration, getTerminalShellConfiguration } from 'vs/workbench/contrib/terminal/common/terminalConfiguration'; +// Register services registerSingleton(ITerminalService, TerminalService, true); -if (platform.isWeb) { - registerShellConfiguration(); -} - -const inTerminalsPicker = 'inTerminalPicker'; +// Register quick accesses const quickAccessRegistry = (Registry.as(QuickAccessExtensions.Quickaccess)); - +const inTerminalsPicker = 'inTerminalPicker'; quickAccessRegistry.registerQuickAccessProvider({ ctor: TerminalQuickAccessProvider, prefix: TerminalQuickAccessProvider.PREFIX, @@ -55,315 +49,21 @@ quickAccessRegistry.registerQuickAccessProvider({ placeholder: nls.localize('tasksQuickAccessPlaceholder', "Type the name of a terminal to open."), helpEntries: [{ description: nls.localize('tasksQuickAccessHelp', "Show All Opened Terminals"), needsEditor: false }] }); - const quickAccessNavigateNextInTerminalPickerId = 'workbench.action.quickOpenNavigateNextInTerminalPicker'; -CommandsRegistry.registerCommand( - { id: quickAccessNavigateNextInTerminalPickerId, handler: getQuickNavigateHandler(quickAccessNavigateNextInTerminalPickerId, true) }); - +CommandsRegistry.registerCommand({ id: quickAccessNavigateNextInTerminalPickerId, handler: getQuickNavigateHandler(quickAccessNavigateNextInTerminalPickerId, true) }); const quickAccessNavigatePreviousInTerminalPickerId = 'workbench.action.quickOpenNavigatePreviousInTerminalPicker'; -CommandsRegistry.registerCommand( - { id: quickAccessNavigatePreviousInTerminalPickerId, handler: getQuickNavigateHandler(quickAccessNavigatePreviousInTerminalPickerId, false) }); - +CommandsRegistry.registerCommand({ id: quickAccessNavigatePreviousInTerminalPickerId, handler: getQuickNavigateHandler(quickAccessNavigatePreviousInTerminalPickerId, false) }); +// Register configurations const configurationRegistry = Registry.as(Extensions.Configuration); -configurationRegistry.registerConfiguration({ - id: 'terminal', - order: 100, - title: nls.localize('terminalIntegratedConfigurationTitle', "Integrated Terminal"), - type: 'object', - properties: { - 'terminal.integrated.automationShell.linux': { - markdownDescription: nls.localize('terminal.integrated.automationShell.linux', "A path that when set will override {0} and ignore {1} values for automation-related terminal usage like tasks and debug.", '`terminal.integrated.shell.linux`', '`shellArgs`'), - type: ['string', 'null'], - default: null - }, - 'terminal.integrated.automationShell.osx': { - markdownDescription: nls.localize('terminal.integrated.automationShell.osx', "A path that when set will override {0} and ignore {1} values for automation-related terminal usage like tasks and debug.", '`terminal.integrated.shell.osx`', '`shellArgs`'), - type: ['string', 'null'], - default: null - }, - 'terminal.integrated.automationShell.windows': { - markdownDescription: nls.localize('terminal.integrated.automationShell.windows', "A path that when set will override {0} and ignore {1} values for automation-related terminal usage like tasks and debug.", '`terminal.integrated.shell.windows`', '`shellArgs`'), - type: ['string', 'null'], - default: null - }, - 'terminal.integrated.shellArgs.linux': { - markdownDescription: nls.localize('terminal.integrated.shellArgs.linux', "The command line arguments to use when on the Linux terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), - type: 'array', - items: { - type: 'string' - }, - default: [] - }, - 'terminal.integrated.shellArgs.osx': { - markdownDescription: nls.localize('terminal.integrated.shellArgs.osx', "The command line arguments to use when on the macOS terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), - type: 'array', - items: { - type: 'string' - }, - // Unlike on Linux, ~/.profile is not sourced when logging into a macOS session. This - // is the reason terminals on macOS typically run login shells by default which set up - // the environment. See http://unix.stackexchange.com/a/119675/115410 - default: ['-l'] - }, - 'terminal.integrated.shellArgs.windows': { - markdownDescription: nls.localize('terminal.integrated.shellArgs.windows', "The command line arguments to use when on the Windows terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), - 'anyOf': [ - { - type: 'array', - items: { - type: 'string', - markdownDescription: nls.localize('terminal.integrated.shellArgs.windows', "The command line arguments to use when on the Windows terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration).") - }, - }, - { - type: 'string', - markdownDescription: nls.localize('terminal.integrated.shellArgs.windows.string', "The command line arguments in [command-line format](https://msdn.microsoft.com/en-au/08dfcab2-eb6e-49a4-80eb-87d4076c98c6) to use when on the Windows terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration).") - } - ], - default: [] - }, - 'terminal.integrated.macOptionIsMeta': { - description: nls.localize('terminal.integrated.macOptionIsMeta', "Controls whether to treat the option key as the meta key in the terminal on macOS."), - type: 'boolean', - default: false - }, - 'terminal.integrated.macOptionClickForcesSelection': { - description: nls.localize('terminal.integrated.macOptionClickForcesSelection', "Controls whether to force selection when using Option+click on macOS. This will force a regular (line) selection and disallow the use of column selection mode. This enables copying and pasting using the regular terminal selection, for example, when mouse mode is enabled in tmux."), - type: 'boolean', - default: false - }, - 'terminal.integrated.copyOnSelection': { - description: nls.localize('terminal.integrated.copyOnSelection', "Controls whether text selected in the terminal will be copied to the clipboard."), - type: 'boolean', - default: false - }, - 'terminal.integrated.drawBoldTextInBrightColors': { - description: nls.localize('terminal.integrated.drawBoldTextInBrightColors', "Controls whether bold text in the terminal will always use the \"bright\" ANSI color variant."), - type: 'boolean', - default: true - }, - 'terminal.integrated.fontFamily': { - markdownDescription: nls.localize('terminal.integrated.fontFamily', "Controls the font family of the terminal, this defaults to `#editor.fontFamily#`'s value."), - type: 'string' - }, - // TODO: Support font ligatures - // 'terminal.integrated.fontLigatures': { - // 'description': nls.localize('terminal.integrated.fontLigatures', "Controls whether font ligatures are enabled in the terminal."), - // 'type': 'boolean', - // 'default': false - // }, - 'terminal.integrated.fontSize': { - description: nls.localize('terminal.integrated.fontSize', "Controls the font size in pixels of the terminal."), - type: 'number', - default: EDITOR_FONT_DEFAULTS.fontSize - }, - 'terminal.integrated.letterSpacing': { - description: nls.localize('terminal.integrated.letterSpacing', "Controls the letter spacing of the terminal, this is an integer value which represents the amount of additional pixels to add between characters."), - type: 'number', - default: DEFAULT_LETTER_SPACING - }, - 'terminal.integrated.lineHeight': { - description: nls.localize('terminal.integrated.lineHeight', "Controls the line height of the terminal, this number is multiplied by the terminal font size to get the actual line-height in pixels."), - type: 'number', - default: DEFAULT_LINE_HEIGHT - }, - 'terminal.integrated.minimumContrastRatio': { - markdownDescription: nls.localize('terminal.integrated.minimumContrastRatio', "When set the foreground color of each cell will change to try meet the contrast ratio specified. Example values:\n\n- 1: The default, do nothing.\n- 4.5: [WCAG AA compliance (minimum)](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html).\n- 7: [WCAG AAA compliance (enhanced)](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast7.html).\n- 21: White on black or black on white."), - type: 'number', - default: 1 - }, - 'terminal.integrated.fastScrollSensitivity': { - markdownDescription: nls.localize('terminal.integrated.fastScrollSensitivity', "Scrolling speed multiplier when pressing `Alt`."), - type: 'number', - default: 5 - }, - 'terminal.integrated.mouseWheelScrollSensitivity': { - markdownDescription: nls.localize('terminal.integrated.mouseWheelScrollSensitivity', "A multiplier to be used on the `deltaY` of mouse wheel scroll events."), - type: 'number', - default: 1 - }, - 'terminal.integrated.fontWeight': { - type: 'string', - enum: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'], - description: nls.localize('terminal.integrated.fontWeight', "The font weight to use within the terminal for non-bold text."), - default: 'normal' - }, - 'terminal.integrated.fontWeightBold': { - type: 'string', - enum: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'], - description: nls.localize('terminal.integrated.fontWeightBold', "The font weight to use within the terminal for bold text."), - default: 'bold' - }, - 'terminal.integrated.cursorBlinking': { - description: nls.localize('terminal.integrated.cursorBlinking', "Controls whether the terminal cursor blinks."), - type: 'boolean', - default: false - }, - 'terminal.integrated.cursorStyle': { - description: nls.localize('terminal.integrated.cursorStyle', "Controls the style of terminal cursor."), - enum: [TerminalCursorStyle.BLOCK, TerminalCursorStyle.LINE, TerminalCursorStyle.UNDERLINE], - default: TerminalCursorStyle.BLOCK - }, - 'terminal.integrated.cursorWidth': { - markdownDescription: nls.localize('terminal.integrated.cursorWidth', "Controls the width of the cursor when `#terminal.integrated.cursorStyle#` is set to `line`."), - type: 'number', - default: 1 - }, - 'terminal.integrated.scrollback': { - description: nls.localize('terminal.integrated.scrollback', "Controls the maximum amount of lines the terminal keeps in its buffer."), - type: 'number', - default: 1000 - }, - 'terminal.integrated.detectLocale': { - markdownDescription: nls.localize('terminal.integrated.detectLocale', "Controls whether to detect and set the `$LANG` environment variable to a UTF-8 compliant option since VS Code's terminal only supports UTF-8 encoded data coming from the shell."), - type: 'string', - enum: ['auto', 'off', 'on'], - markdownEnumDescriptions: [ - nls.localize('terminal.integrated.detectLocale.auto', "Set the `$LANG` environment variable if the existing variable does not exist or it does not end in `'.UTF-8'`."), - nls.localize('terminal.integrated.detectLocale.off', "Do not set the `$LANG` environment variable."), - nls.localize('terminal.integrated.detectLocale.on', "Always set the `$LANG` environment variable.") - ], - default: 'auto' - }, - 'terminal.integrated.rendererType': { - type: 'string', - enum: ['auto', 'canvas', 'dom', 'experimentalWebgl'], - markdownEnumDescriptions: [ - nls.localize('terminal.integrated.rendererType.auto', "Let VS Code guess which renderer to use."), - nls.localize('terminal.integrated.rendererType.canvas', "Use the standard GPU/canvas-based renderer."), - nls.localize('terminal.integrated.rendererType.dom', "Use the fallback DOM-based renderer."), - nls.localize('terminal.integrated.rendererType.experimentalWebgl', "Use the experimental webgl-based renderer. Note that this has some [known issues](https://github.com/xtermjs/xterm.js/issues?q=is%3Aopen+is%3Aissue+label%3Aarea%2Faddon%2Fwebgl) and this will only be enabled for new terminals (not hot swappable like the other renderers).") - ], - default: 'auto', - description: nls.localize('terminal.integrated.rendererType', "Controls how the terminal is rendered.") - }, - 'terminal.integrated.rightClickBehavior': { - type: 'string', - enum: ['default', 'copyPaste', 'paste', 'selectWord'], - enumDescriptions: [ - nls.localize('terminal.integrated.rightClickBehavior.default', "Show the context menu."), - nls.localize('terminal.integrated.rightClickBehavior.copyPaste', "Copy when there is a selection, otherwise paste."), - nls.localize('terminal.integrated.rightClickBehavior.paste', "Paste on right click."), - nls.localize('terminal.integrated.rightClickBehavior.selectWord', "Select the word under the cursor and show the context menu.") - ], - default: platform.isMacintosh ? 'selectWord' : platform.isWindows ? 'copyPaste' : 'default', - description: nls.localize('terminal.integrated.rightClickBehavior', "Controls how terminal reacts to right click.") - }, - 'terminal.integrated.cwd': { - description: nls.localize('terminal.integrated.cwd', "An explicit start path where the terminal will be launched, this is used as the current working directory (cwd) for the shell process. This may be particularly useful in workspace settings if the root directory is not a convenient cwd."), - type: 'string', - default: undefined - }, - 'terminal.integrated.confirmOnExit': { - description: nls.localize('terminal.integrated.confirmOnExit', "Controls whether to confirm on exit if there are active terminal sessions."), - type: 'boolean', - default: false - }, - 'terminal.integrated.enableBell': { - description: nls.localize('terminal.integrated.enableBell', "Controls whether the terminal bell is enabled."), - type: 'boolean', - default: false - }, - 'terminal.integrated.commandsToSkipShell': { - markdownDescription: nls.localize('terminal.integrated.commandsToSkipShell', "A set of command IDs whose keybindings will not be sent to the shell and instead always be handled by Code. This allows the use of keybindings that would normally be consumed by the shell to act the same as when the terminal is not focused, for example ctrl+p to launch Quick Open.\nDefault Skipped Commands:\n\n{0}", DEFAULT_COMMANDS_TO_SKIP_SHELL.sort().map(command => `- ${command}`).join('\n')), - type: 'array', - items: { - type: 'string' - }, - default: [] - }, - 'terminal.integrated.allowChords': { - markdownDescription: nls.localize('terminal.integrated.allowChords', "Whether or not to allow chord keybindings in the terminal. Note that when this is true and the keystroke results in a chord it will bypass `#terminal.integrated.commandsToSkipShell#`, setting this to false is particularly useful when you want ctrl+k to go to your shell (not VS Code)."), - type: 'boolean', - default: true - }, - 'terminal.integrated.allowMnemonics': { - markdownDescription: nls.localize('terminal.integrated.allowMnemonics', "Whether to allow menubar mnemonics (eg. alt+f) to trigger the open the menubar. Note that this will cause all alt keystrokes will skip the shell when true. This does nothing on macOS."), - type: 'boolean', - default: false - }, - 'terminal.integrated.inheritEnv': { - markdownDescription: nls.localize('terminal.integrated.inheritEnv', "Whether new shells should inherit their environment from VS Code. This is not supported on Windows."), - type: 'boolean', - default: true - }, - 'terminal.integrated.env.osx': { - markdownDescription: nls.localize('terminal.integrated.env.osx', "Object with environment variables that will be added to the VS Code process to be used by the terminal on macOS. Set to `null` to delete the environment variable."), - type: 'object', - additionalProperties: { - type: ['string', 'null'] - }, - default: {} - }, - 'terminal.integrated.env.linux': { - markdownDescription: nls.localize('terminal.integrated.env.linux', "Object with environment variables that will be added to the VS Code process to be used by the terminal on Linux. Set to `null` to delete the environment variable."), - type: 'object', - additionalProperties: { - type: ['string', 'null'] - }, - default: {} - }, - 'terminal.integrated.env.windows': { - markdownDescription: nls.localize('terminal.integrated.env.windows', "Object with environment variables that will be added to the VS Code process to be used by the terminal on Windows. Set to `null` to delete the environment variable."), - type: 'object', - additionalProperties: { - type: ['string', 'null'] - }, - default: {} - }, - 'terminal.integrated.showExitAlert': { - description: nls.localize('terminal.integrated.showExitAlert', "Controls whether to show the alert \"The terminal process terminated with exit code\" when exit code is non-zero."), - type: 'boolean', - default: true - }, - 'terminal.integrated.splitCwd': { - description: nls.localize('terminal.integrated.splitCwd', "Controls the working directory a split terminal starts with."), - type: 'string', - enum: ['workspaceRoot', 'initial', 'inherited'], - enumDescriptions: [ - nls.localize('terminal.integrated.splitCwd.workspaceRoot', "A new split terminal will use the workspace root as the working directory. In a multi-root workspace a choice for which root folder to use is offered."), - nls.localize('terminal.integrated.splitCwd.initial', "A new split terminal will use the working directory that the parent terminal started with."), - nls.localize('terminal.integrated.splitCwd.inherited', "On macOS and Linux, a new split terminal will use the working directory of the parent terminal. On Windows, this behaves the same as initial."), - ], - default: 'inherited' - }, - 'terminal.integrated.windowsEnableConpty': { - description: nls.localize('terminal.integrated.windowsEnableConpty', "Whether to use ConPTY for Windows terminal process communication (requires Windows 10 build number 18309+). Winpty will be used if this is false."), - type: 'boolean', - default: true - }, - 'terminal.integrated.wordSeparators': { - description: nls.localize('terminal.integrated.wordSeparators', "A string containing all characters to be considered word separators by the double click to select word feature."), - type: 'string', - default: ' ()[]{}\',"`' - }, - 'terminal.integrated.experimentalUseTitleEvent': { - description: nls.localize('terminal.integrated.experimentalUseTitleEvent', "An experimental setting that will use the terminal title event for the dropdown title. This setting will only apply to new terminals."), - type: 'boolean', - default: false - }, - 'terminal.integrated.enableFileLinks': { - description: nls.localize('terminal.integrated.enableFileLinks', "Whether to enable file links in the terminal. Links can be slow when working on a network drive in particular because each file link is verified against the file system."), - type: 'boolean', - default: true - }, - 'terminal.integrated.unicodeVersion': { - type: 'string', - enum: ['6', '11'], - enumDescriptions: [ - nls.localize('terminal.integrated.unicodeVersion.six', "Version 6 of unicode, this is an older version which should work better on older systems."), - nls.localize('terminal.integrated.unicodeVersion.eleven', "Version 11 of unicode, this version provides better support on modern systems that use modern versions of unicode.") - ], - default: '11', - description: nls.localize('terminal.integrated.unicodeVersion', "Controls what version of unicode to use when evaluating the width of characters in the terminal. If you experience emoji or other wide characters not taking up the right amount of space or backspace either deleting too much or too little then you may want to try tweaking this setting.") - } - } -}); - -const registry = Registry.as(ActionExtensions.WorkbenchActions); -registry.registerWorkbenchAction(SyncActionDescriptor.create(QuickAccessTerminalAction, QuickAccessTerminalAction.ID, QuickAccessTerminalAction.LABEL), 'Terminal: Switch Active Terminal', nls.localize('terminal', "Terminal")); +configurationRegistry.registerConfiguration(terminalConfiguration); +if (platform.isWeb) { + // Desktop shell configuration are registered in electron-browser as their default values rely + // on process.env + configurationRegistry.registerConfiguration(getTerminalShellConfiguration()); +} +// Register views const VIEW_CONTAINER = Registry.as(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer({ id: TERMINAL_VIEW_ID, name: nls.localize('terminal', "Terminal"), @@ -373,7 +73,6 @@ const VIEW_CONTAINER = Registry.as(ViewContainerExtensi order: 3 }, ViewContainerLocation.Panel); Registry.as(panel.Extensions.Panels).setDefaultPanelId(TERMINAL_VIEW_ID); - Registry.as(ViewContainerExtensions.ViewsRegistry).registerViews([{ id: TERMINAL_VIEW_ID, name: nls.localize('terminal', "Terminal"), @@ -383,22 +82,15 @@ Registry.as(ViewContainerExtensions.ViewsRegistry).registerViews ctorDescriptor: new SyncDescriptor(TerminalViewPane) }], VIEW_CONTAINER); -// On mac cmd+` is reserved to cycle between windows, that's why the keybindings use WinCtrl -const category = TERMINAL_ACTION_CATEGORY; +// Register actions const actionRegistry = Registry.as(ActionExtensions.WorkbenchActions); +registerTerminalActions(); +const category = TERMINAL_ACTION_CATEGORY; actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(KillTerminalAction, KillTerminalAction.ID, KillTerminalAction.LABEL), 'Terminal: Kill the Active Terminal Instance', category); actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(CreateNewTerminalAction, CreateNewTerminalAction.ID, CreateNewTerminalAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_BACKTICK, mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.US_BACKTICK } }), 'Terminal: Create New Integrated Terminal', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ClearSelectionTerminalAction, ClearSelectionTerminalAction.ID, ClearSelectionTerminalAction.LABEL, { - primary: KeyCode.Escape, - linux: { primary: KeyCode.Escape } -}, ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_NOT_VISIBLE)), 'Terminal: Clear Selection', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(CreateNewInActiveWorkspaceTerminalAction, CreateNewInActiveWorkspaceTerminalAction.ID, CreateNewInActiveWorkspaceTerminalAction.LABEL), 'Terminal: Create New Integrated Terminal (In Active Workspace)', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(FocusActiveTerminalAction, FocusActiveTerminalAction.ID, FocusActiveTerminalAction.LABEL), 'Terminal: Focus Terminal', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(FocusNextTerminalAction, FocusNextTerminalAction.ID, FocusNextTerminalAction.LABEL), 'Terminal: Focus Next Terminal', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(FocusPreviousTerminalAction, FocusPreviousTerminalAction.ID, FocusPreviousTerminalAction.LABEL), 'Terminal: Focus Previous Terminal', category); actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(SelectAllTerminalAction, SelectAllTerminalAction.ID, SelectAllTerminalAction.LABEL, { // Don't use ctrl+a by default as that would override the common go to start // of prompt shell binding @@ -408,50 +100,17 @@ actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(SelectAllTerm // makes it easier for users to see how it works though. mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_A } }, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Select All', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(RunSelectedTextInTerminalAction, RunSelectedTextInTerminalAction.ID, RunSelectedTextInTerminalAction.LABEL), 'Terminal: Run Selected Text In Active Terminal', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(RunActiveFileInTerminalAction, RunActiveFileInTerminalAction.ID, RunActiveFileInTerminalAction.LABEL), 'Terminal: Run Active File In Active Terminal', category); actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ToggleTerminalAction, ToggleTerminalAction.ID, ToggleTerminalAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.US_BACKTICK, mac: { primary: KeyMod.WinCtrl | KeyCode.US_BACKTICK } }), 'View: Toggle Integrated Terminal', nls.localize('viewCategory', "View")); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ScrollDownTerminalAction, ScrollDownTerminalAction.ID, ScrollDownTerminalAction.LABEL, { - primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageDown, - linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.DownArrow } -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Scroll Down (Line)', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ScrollDownPageTerminalAction, ScrollDownPageTerminalAction.ID, ScrollDownPageTerminalAction.LABEL, { - primary: KeyMod.Shift | KeyCode.PageDown, - mac: { primary: KeyCode.PageDown } -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Scroll Down (Page)', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ScrollToBottomTerminalAction, ScrollToBottomTerminalAction.ID, ScrollToBottomTerminalAction.LABEL, { - primary: KeyMod.CtrlCmd | KeyCode.End, - linux: { primary: KeyMod.Shift | KeyCode.End } -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Scroll to Bottom', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ScrollUpTerminalAction, ScrollUpTerminalAction.ID, ScrollUpTerminalAction.LABEL, { - primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageUp, - linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.UpArrow }, -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Scroll Up (Line)', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ScrollUpPageTerminalAction, ScrollUpPageTerminalAction.ID, ScrollUpPageTerminalAction.LABEL, { - primary: KeyMod.Shift | KeyCode.PageUp, - mac: { primary: KeyCode.PageUp } -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Scroll Up (Page)', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ScrollToTopTerminalAction, ScrollToTopTerminalAction.ID, ScrollToTopTerminalAction.LABEL, { - primary: KeyMod.CtrlCmd | KeyCode.Home, - linux: { primary: KeyMod.Shift | KeyCode.Home } -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Scroll to Top', category); +// Weight is higher than work workbench contributions so the keybinding remains +// highest priority when chords are registered afterwards actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ClearTerminalAction, ClearTerminalAction.ID, ClearTerminalAction.LABEL, { primary: 0, mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_K } }, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KeybindingWeight.WorkbenchContrib + 1), 'Terminal: Clear', category); actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(SelectDefaultShellWindowsTerminalAction, SelectDefaultShellWindowsTerminalAction.ID, SelectDefaultShellWindowsTerminalAction.LABEL), 'Terminal: Select Default Shell', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ManageWorkspaceShellPermissionsTerminalCommand, ManageWorkspaceShellPermissionsTerminalCommand.ID, ManageWorkspaceShellPermissionsTerminalCommand.LABEL), 'Terminal: Manage Workspace Shell Permissions', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(RenameTerminalAction, RenameTerminalAction.ID, RenameTerminalAction.LABEL), 'Terminal: Rename', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(FocusTerminalFindWidgetAction, FocusTerminalFindWidgetAction.ID, FocusTerminalFindWidgetAction.LABEL, { - primary: KeyMod.CtrlCmd | KeyCode.KEY_F -}, ContextKeyExpr.or(KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED, KEYBINDING_CONTEXT_TERMINAL_FOCUS)), 'Terminal: Focus Find Widget', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(HideTerminalFindWidgetAction, HideTerminalFindWidgetAction.ID, HideTerminalFindWidgetAction.LABEL, { - primary: KeyCode.Escape, - secondary: [KeyMod.Shift | KeyCode.Escape] -}, ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE)), 'Terminal: Hide Find Widget', category); actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(SplitTerminalAction, SplitTerminalAction.ID, SplitTerminalAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_5, mac: { @@ -460,98 +119,6 @@ actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(SplitTerminal } }, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Split Terminal', category); actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(SplitInActiveWorkspaceTerminalAction, SplitInActiveWorkspaceTerminalAction.ID, SplitInActiveWorkspaceTerminalAction.LABEL), 'Terminal: Split Terminal (In Active Workspace)', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(FocusPreviousPaneTerminalAction, FocusPreviousPaneTerminalAction.ID, FocusPreviousPaneTerminalAction.LABEL, { - primary: KeyMod.Alt | KeyCode.LeftArrow, - secondary: [KeyMod.Alt | KeyCode.UpArrow], - mac: { - primary: KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.LeftArrow, - secondary: [KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.UpArrow] - } -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Focus Previous Pane', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(FocusNextPaneTerminalAction, FocusNextPaneTerminalAction.ID, FocusNextPaneTerminalAction.LABEL, { - primary: KeyMod.Alt | KeyCode.RightArrow, - secondary: [KeyMod.Alt | KeyCode.DownArrow], - mac: { - primary: KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.RightArrow, - secondary: [KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.DownArrow] - } -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Focus Next Pane', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ResizePaneLeftTerminalAction, ResizePaneLeftTerminalAction.ID, ResizePaneLeftTerminalAction.LABEL, { - primary: 0, - linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.LeftArrow }, - mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.LeftArrow } -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Resize Pane Left', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ResizePaneRightTerminalAction, ResizePaneRightTerminalAction.ID, ResizePaneRightTerminalAction.LABEL, { - primary: 0, - linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.RightArrow }, - mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.RightArrow } -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Resize Pane Right', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ResizePaneUpTerminalAction, ResizePaneUpTerminalAction.ID, ResizePaneUpTerminalAction.LABEL, { - primary: 0, - mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.UpArrow } -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Resize Pane Up', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ResizePaneDownTerminalAction, ResizePaneDownTerminalAction.ID, ResizePaneDownTerminalAction.LABEL, { - primary: 0, - mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.DownArrow } -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Resize Pane Down', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ScrollToPreviousCommandAction, ScrollToPreviousCommandAction.ID, ScrollToPreviousCommandAction.LABEL, { - primary: 0, - mac: { primary: KeyMod.CtrlCmd | KeyCode.UpArrow } -}, ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate())), 'Terminal: Scroll To Previous Command', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ScrollToNextCommandAction, ScrollToNextCommandAction.ID, ScrollToNextCommandAction.LABEL, { - primary: 0, - mac: { primary: KeyMod.CtrlCmd | KeyCode.DownArrow } -}, ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate())), 'Terminal: Scroll To Next Command', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(SelectToPreviousCommandAction, SelectToPreviousCommandAction.ID, SelectToPreviousCommandAction.LABEL, { - primary: 0, - mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.UpArrow } -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Select To Previous Command', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(SelectToNextCommandAction, SelectToNextCommandAction.ID, SelectToNextCommandAction.LABEL, { - primary: 0, - mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.DownArrow } -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Select To Next Command', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(NavigationModeExitTerminalAction, NavigationModeExitTerminalAction.ID, NavigationModeExitTerminalAction.LABEL, { - primary: KeyCode.Escape -}, ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, CONTEXT_ACCESSIBILITY_MODE_ENABLED)), 'Terminal: Exit Navigation Mode', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(NavigationModeFocusPreviousTerminalAction, NavigationModeFocusPreviousTerminalAction.ID, NavigationModeFocusPreviousTerminalAction.LABEL, { - primary: KeyMod.CtrlCmd | KeyCode.UpArrow -}, ContextKeyExpr.or(ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, CONTEXT_ACCESSIBILITY_MODE_ENABLED), ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, CONTEXT_ACCESSIBILITY_MODE_ENABLED))), 'Terminal: Focus Previous Line (Navigation Mode)', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(NavigationModeFocusNextTerminalAction, NavigationModeFocusNextTerminalAction.ID, NavigationModeFocusNextTerminalAction.LABEL, { - primary: KeyMod.CtrlCmd | KeyCode.DownArrow -}, ContextKeyExpr.or(ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, CONTEXT_ACCESSIBILITY_MODE_ENABLED), ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, CONTEXT_ACCESSIBILITY_MODE_ENABLED))), 'Terminal: Focus Next Line (Navigation Mode)', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(SelectToPreviousLineAction, SelectToPreviousLineAction.ID, SelectToPreviousLineAction.LABEL), 'Terminal: Select To Previous Line', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(SelectToNextLineAction, SelectToNextLineAction.ID, SelectToNextLineAction.LABEL), 'Terminal: Select To Next Line', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ToggleEscapeSequenceLoggingAction, ToggleEscapeSequenceLoggingAction.ID, ToggleEscapeSequenceLoggingAction.LABEL), 'Terminal: Toggle Escape Sequence Logging', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ToggleRegexCommand, ToggleRegexCommand.ID, ToggleRegexCommand.LABEL, { - primary: KeyMod.Alt | KeyCode.KEY_R, - mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_R } -}, ContextKeyExpr.or(KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED)), 'Terminal: Toggle find using regex', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ToggleWholeWordCommand, ToggleWholeWordCommand.ID, ToggleWholeWordCommand.LABEL, { - primary: KeyMod.Alt | KeyCode.KEY_W, - mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_W } -}, ContextKeyExpr.or(KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED)), 'Terminal: Toggle find using whole word', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ToggleCaseSensitiveCommand, ToggleCaseSensitiveCommand.ID, ToggleCaseSensitiveCommand.LABEL, { - primary: KeyMod.Alt | KeyCode.KEY_C, - mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_C } -}, ContextKeyExpr.or(KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED)), 'Terminal: Toggle find using case sensitive', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(FindNext, FindNext.ID, FindNext.LABEL, { - primary: KeyCode.F3, - mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_G, secondary: [KeyCode.F3] } -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Find next', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(FindNext, FindNext.ID, FindNext.LABEL, { - primary: KeyCode.F3, - secondary: [KeyMod.Shift | KeyCode.Enter], - mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_G, secondary: [KeyCode.F3, KeyMod.Shift | KeyCode.Enter] } -}, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED), 'Terminal: Find next', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(FindPrevious, FindPrevious.ID, FindPrevious.LABEL, { - primary: KeyMod.Shift | KeyCode.F3, - mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_G, secondary: [KeyMod.Shift | KeyCode.F3] }, -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Find previous', category); -actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(FindPrevious, FindPrevious.ID, FindPrevious.LABEL, { - primary: KeyMod.Shift | KeyCode.F3, - secondary: [KeyCode.Enter], - mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_G, secondary: [KeyMod.Shift | KeyCode.F3, KeyCode.Enter] }, -}, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED), 'Terminal: Find previous', category); // Commands might be affected by Web restrictons if (BrowserFeatures.clipboard.writeText) { @@ -564,7 +131,7 @@ if (BrowserFeatures.clipboard.writeText) { function registerSendSequenceKeybinding(text: string, rule: { when?: ContextKeyExpression } & IKeybindings): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ - id: SendSequenceTerminalAction.ID, + id: TERMINAL_COMMAND_ID.SEND_SEQUENCE, weight: KeybindingWeight.WorkbenchContrib, when: rule.when || KEYBINDING_CONTEXT_TERMINAL_FOCUS, primary: rule.primary, @@ -615,77 +182,6 @@ registerSendSequenceKeybinding(String.fromCharCode('E'.charCodeAt(0) - 64), { mac: { primary: KeyMod.CtrlCmd | KeyCode.RightArrow } }); -registerAction2(class extends SendSequenceTerminalAction { - constructor() { - super({ - id: SendSequenceTerminalAction.ID, - title: SendSequenceTerminalAction.LABEL, - description: { - description: SendSequenceTerminalAction.LABEL, - args: [{ - name: 'args', - schema: { - type: 'object', - required: ['text'], - properties: { - text: { type: 'string' } - }, - } - }] - } - }); - } -}); -registerAction2(class extends CreateNewWithCwdTerminalAction { - constructor() { - super({ - id: CreateNewWithCwdTerminalAction.ID, - title: CreateNewWithCwdTerminalAction.LABEL, - description: { - description: CreateNewWithCwdTerminalAction.LABEL, - args: [{ - name: 'args', - schema: { - type: 'object', - required: ['cwd'], - properties: { - cwd: { - description: CreateNewWithCwdTerminalAction.CWD_ARG_LABEL, - type: 'string' - } - }, - } - }] - } - }); - } -}); -registerAction2(class extends RenameWithArgTerminalAction { - constructor() { - super({ - id: RenameWithArgTerminalAction.ID, - title: RenameWithArgTerminalAction.LABEL, - description: { - description: RenameWithArgTerminalAction.LABEL, - args: [{ - name: 'args', - schema: { - type: 'object', - required: ['name'], - properties: { - name: { - description: RenameWithArgTerminalAction.NAME_ARG_LABEL, - type: 'string', - minLength: 1 - } - } - } - }] - } - }); - } -}); - setupTerminalCommands(); setupTerminalMenu(); diff --git a/src/vs/workbench/contrib/terminal/browser/terminal.ts b/src/vs/workbench/contrib/terminal/browser/terminal.ts index 15afd525b6c..e33616878ab 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminal.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminal.ts @@ -112,6 +112,13 @@ export interface ITerminalService { getActiveOrCreateInstance(): ITerminalInstance; splitInstance(instance: ITerminalInstance, shell?: IShellLaunchConfig): ITerminalInstance | null; + /** + * Perform an action with the active terminal instance, if the terminal does + * not exist the callback will not be called. + * @param callback The callback that fires with the active terminal + */ + doWithActiveInstance(callback: (terminal: ITerminalInstance) => T): T | void; + getActiveTab(): ITerminalTab | null; setActiveTabToNext(): void; setActiveTabToPrevious(): void; diff --git a/src/vs/workbench/contrib/terminal/browser/terminalActions.ts b/src/vs/workbench/contrib/terminal/browser/terminalActions.ts index 8dbec9aae38..56aa1d47225 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalActions.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalActions.ts @@ -3,11 +3,10 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as nls from 'vs/nls'; import { Action, IAction } from 'vs/base/common/actions'; import { EndOfLinePreference } from 'vs/editor/common/model'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; -import { TERMINAL_VIEW_ID, ITerminalConfigHelper, TitleEventSource, TERMINAL_COMMAND_ID } from 'vs/workbench/contrib/terminal/common/terminal'; +import { TERMINAL_VIEW_ID, ITerminalConfigHelper, TitleEventSource, TERMINAL_COMMAND_ID, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED, TERMINAL_ACTION_CATEGORY, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_NOT_VISIBLE, KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS } from 'vs/workbench/contrib/terminal/common/terminal'; import { SelectActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { attachSelectBoxStyler, attachStylerCallback } from 'vs/platform/theme/common/styler'; @@ -19,7 +18,6 @@ import { ICommandService } from 'vs/platform/commands/common/commands'; import { IWorkspaceContextService, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; import { PICK_WORKSPACE_FOLDER_COMMAND_ID } from 'vs/workbench/browser/actions/workspaceCommands'; import { INotificationService } from 'vs/platform/notification/common/notification'; -import { FindReplaceState } from 'vs/editor/contrib/find/findState'; import { ISelectOptionItem } from 'vs/base/browser/ui/selectBox/selectBox'; import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; import { IHistoryService } from 'vs/workbench/services/history/common/history'; @@ -28,13 +26,17 @@ import { URI } from 'vs/base/common/uri'; import { isWindows } from 'vs/base/common/platform'; import { withNullAsUndefined } from 'vs/base/common/types'; import { ITerminalInstance, ITerminalService, Direction } from 'vs/workbench/contrib/terminal/browser/terminal'; -import { Action2 } from 'vs/platform/actions/common/actions'; +import { Action2, registerAction2 } from 'vs/platform/actions/common/actions'; import { TerminalQuickAccessProvider } from 'vs/workbench/contrib/terminal/browser/terminalsQuickAccess'; import { ToggleViewAction } from 'vs/workbench/browser/actions/layoutActions'; import { IViewsService, IViewDescriptorService } from 'vs/workbench/common/views'; -import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { addClass } from 'vs/base/browser/dom'; import { selectBorder } from 'vs/platform/theme/common/colorRegistry'; +import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { localize } from 'vs/nls'; +import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vs/platform/accessibility/common/accessibility'; async function getCwdForSplit(configHelper: ITerminalConfigHelper, instance: ITerminalInstance, folders?: IWorkspaceFolder[], commandService?: ICommandService): Promise { switch (configHelper.config.splitCwd) { @@ -45,7 +47,7 @@ async function getCwdForSplit(configHelper: ITerminalConfigHelper, instance: ITe } else if (folders.length > 1) { // Only choose a path when there's more than 1 folder const options: IPickOptions = { - placeHolder: nls.localize('workbench.action.terminal.newWorkspacePlaceholder', "Select current working directory for new terminal") + placeHolder: localize('workbench.action.terminal.newWorkspacePlaceholder', "Select current working directory for new terminal") }; const workspace = await commandService.executeCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, [options]); if (!workspace) { @@ -66,7 +68,7 @@ async function getCwdForSplit(configHelper: ITerminalConfigHelper, instance: ITe export class ToggleTerminalAction extends ToggleViewAction { public static readonly ID = TERMINAL_COMMAND_ID.TOGGLE; - public static readonly LABEL = nls.localize('workbench.action.terminal.toggleTerminal', "Toggle Integrated Terminal"); + public static readonly LABEL = localize('workbench.action.terminal.toggleTerminal', "Toggle Integrated Terminal"); constructor( id: string, label: string, @@ -79,7 +81,7 @@ export class ToggleTerminalAction extends ToggleViewAction { super(id, label, TERMINAL_VIEW_ID, viewsService, viewDescriptorService, contextKeyService, layoutService); } - public run(event?: any): Promise { + async run() { if (this.terminalService.terminalInstances.length === 0) { // If there is not yet an instance attempt to create it here so that we can suggest a // new shell on Windows (and not do so when the panel is restored on reload). @@ -96,25 +98,23 @@ export class ToggleTerminalAction extends ToggleViewAction { export class KillTerminalAction extends Action { public static readonly ID = TERMINAL_COMMAND_ID.KILL; - public static readonly LABEL = nls.localize('workbench.action.terminal.kill', "Kill the Active Terminal Instance"); - public static readonly PANEL_LABEL = nls.localize('workbench.action.terminal.kill.short', "Kill Terminal"); + public static readonly LABEL = localize('workbench.action.terminal.kill', "Kill the Active Terminal Instance"); + public static readonly PANEL_LABEL = localize('workbench.action.terminal.kill.short', "Kill Terminal"); constructor( id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService + @ITerminalService private readonly _terminalService: ITerminalService ) { super(id, label, 'terminal-action codicon-trash'); } - public run(event?: any): Promise { - const instance = this.terminalService.getActiveInstance(); - if (instance) { - instance.dispose(true); - if (this.terminalService.terminalInstances.length > 0) { - this.terminalService.showPanel(true); + async run() { + await this._terminalService.doWithActiveInstance(async t => { + t.dispose(true); + if (this._terminalService.terminalInstances.length > 0) { + await this._terminalService.showPanel(true); } - } - return Promise.resolve(undefined); + }); } } @@ -125,110 +125,77 @@ export class KillTerminalAction extends Action { export class CopyTerminalSelectionAction extends Action { public static readonly ID = TERMINAL_COMMAND_ID.COPY_SELECTION; - public static readonly LABEL = nls.localize('workbench.action.terminal.copySelection', "Copy Selection"); - public static readonly SHORT_LABEL = nls.localize('workbench.action.terminal.copySelection.short', "Copy"); + public static readonly LABEL = localize('workbench.action.terminal.copySelection', "Copy Selection"); + public static readonly SHORT_LABEL = localize('workbench.action.terminal.copySelection.short', "Copy"); constructor( id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService + @ITerminalService private readonly _terminalService: ITerminalService ) { super(id, label); } - public async run(event?: any): Promise { - const terminalInstance = this.terminalService.getActiveInstance(); - if (terminalInstance) { - await terminalInstance.copySelection(); - } - return Promise.resolve(undefined); + async run() { + await this._terminalService.getActiveInstance()?.copySelection(); } } export class SelectAllTerminalAction extends Action { public static readonly ID = TERMINAL_COMMAND_ID.SELECT_ALL; - public static readonly LABEL = nls.localize('workbench.action.terminal.selectAll', "Select All"); + public static readonly LABEL = localize('workbench.action.terminal.selectAll', "Select All"); constructor( id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService + @ITerminalService private readonly _terminalService: ITerminalService ) { super(id, label); } - public run(event?: any): Promise { - const terminalInstance = this.terminalService.getActiveInstance(); - if (terminalInstance) { - terminalInstance.selectAll(); + async run() { + this._terminalService.getActiveInstance()?.selectAll(); + } +} + +export const terminalSendSequenceCommand = (accessor: ServicesAccessor, args: { text?: string } | undefined) => { + accessor.get(ITerminalService).doWithActiveInstance(t => { + if (!args?.text) { + return; } - return Promise.resolve(undefined); - } -} - - -export class SendSequenceTerminalAction extends Action2 { - public static readonly ID = TERMINAL_COMMAND_ID.SEND_SEQUENCE; - public static readonly LABEL = nls.localize('workbench.action.terminal.sendSequence', "Send Custom Sequence To Terminal"); - - public run(accessor: ServicesAccessor, args: any): void { - terminalSendSequenceCommand(accessor, args); - } -} - -export const terminalSendSequenceCommand = (accessor: ServicesAccessor, args: any) => { - const terminalInstance = accessor.get(ITerminalService).getActiveInstance(); - if (!terminalInstance) { - return; - } - - const configurationResolverService = accessor.get(IConfigurationResolverService); - const workspaceContextService = accessor.get(IWorkspaceContextService); - const historyService = accessor.get(IHistoryService); - const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot(Schemas.file); - const lastActiveWorkspaceRoot = activeWorkspaceRootUri ? withNullAsUndefined(workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri)) : undefined; - const resolvedText = configurationResolverService.resolve(lastActiveWorkspaceRoot, args.text); - terminalInstance.sendText(resolvedText, false); + const configurationResolverService = accessor.get(IConfigurationResolverService); + const workspaceContextService = accessor.get(IWorkspaceContextService); + const historyService = accessor.get(IHistoryService); + const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot(Schemas.file); + const lastActiveWorkspaceRoot = activeWorkspaceRootUri ? withNullAsUndefined(workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri)) : undefined; + const resolvedText = configurationResolverService.resolve(lastActiveWorkspaceRoot, args.text); + t.sendText(resolvedText, false); + }); }; -export class CreateNewWithCwdTerminalAction extends Action2 { - public static readonly ID = TERMINAL_COMMAND_ID.NEW_WITH_CWD; - public static readonly LABEL = nls.localize('workbench.action.terminal.newWithCwd', "Create New Integrated Terminal Starting in a Custom Working Directory"); - public static readonly CWD_ARG_LABEL = nls.localize('workbench.action.terminal.newWithCwd.cwd', "The directory to start the terminal at"); - - public run(accessor: ServicesAccessor, args: { cwd: string } | undefined): Promise { - const terminalService = accessor.get(ITerminalService); - const instance = terminalService.createTerminal({ cwd: args?.cwd }); - if (!instance) { - return Promise.resolve(undefined); - } - terminalService.setActiveInstance(instance); - return terminalService.showPanel(true); - } -} export class CreateNewTerminalAction extends Action { public static readonly ID = TERMINAL_COMMAND_ID.NEW; - public static readonly LABEL = nls.localize('workbench.action.terminal.new', "Create New Integrated Terminal"); - public static readonly SHORT_LABEL = nls.localize('workbench.action.terminal.new.short', "New Terminal"); + public static readonly LABEL = localize('workbench.action.terminal.new', "Create New Integrated Terminal"); + public static readonly SHORT_LABEL = localize('workbench.action.terminal.new.short', "New Terminal"); constructor( id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService, - @ICommandService private readonly commandService: ICommandService, - @IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService + @ITerminalService private readonly _terminalService: ITerminalService, + @ICommandService private readonly _commandService: ICommandService, + @IWorkspaceContextService private readonly _workspaceContextService: IWorkspaceContextService ) { super(id, label, 'terminal-action codicon-add'); } - public async run(event?: any): Promise { - const folders = this.workspaceContextService.getWorkspace().folders; + async run(event?: any) { + const folders = this._workspaceContextService.getWorkspace().folders; if (event instanceof MouseEvent && (event.altKey || event.ctrlKey)) { - const activeInstance = this.terminalService.getActiveInstance(); + const activeInstance = this._terminalService.getActiveInstance(); if (activeInstance) { - const cwd = await getCwdForSplit(this.terminalService.configHelper, activeInstance); - this.terminalService.splitInstance(activeInstance, { cwd }); - return undefined; + const cwd = await getCwdForSplit(this._terminalService.configHelper, activeInstance); + this._terminalService.splitInstance(activeInstance, { cwd }); + return; } } @@ -236,78 +203,54 @@ export class CreateNewTerminalAction extends Action { if (folders.length <= 1) { // Allow terminal service to handle the path when there is only a // single root - instance = this.terminalService.createTerminal(undefined); + instance = this._terminalService.createTerminal(undefined); } else { const options: IPickOptions = { - placeHolder: nls.localize('workbench.action.terminal.newWorkspacePlaceholder', "Select current working directory for new terminal") + placeHolder: localize('workbench.action.terminal.newWorkspacePlaceholder', "Select current working directory for new terminal") }; - const workspace = await this.commandService.executeCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, [options]); + const workspace = await this._commandService.executeCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, [options]); if (!workspace) { // Don't create the instance if the workspace picker was canceled - return undefined; + return; } - instance = this.terminalService.createTerminal({ cwd: workspace.uri }); + instance = this._terminalService.createTerminal({ cwd: workspace.uri }); } - this.terminalService.setActiveInstance(instance); - return this.terminalService.showPanel(true); - } -} - -export class CreateNewInActiveWorkspaceTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.NEW_IN_ACTIVE_WORKSPACE; - public static readonly LABEL = nls.localize('workbench.action.terminal.newInActiveWorkspace', "Create New Integrated Terminal (In Active Workspace)"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - const instance = this.terminalService.createTerminal(undefined); - if (!instance) { - return Promise.resolve(undefined); - } - this.terminalService.setActiveInstance(instance); - return this.terminalService.showPanel(true); + this._terminalService.setActiveInstance(instance); + await this._terminalService.showPanel(true); } } export class SplitTerminalAction extends Action { public static readonly ID = TERMINAL_COMMAND_ID.SPLIT; - public static readonly LABEL = nls.localize('workbench.action.terminal.split', "Split Terminal"); - public static readonly SHORT_LABEL = nls.localize('workbench.action.terminal.split.short', "Split"); + public static readonly LABEL = localize('workbench.action.terminal.split', "Split Terminal"); + public static readonly SHORT_LABEL = localize('workbench.action.terminal.split.short', "Split"); public static readonly HORIZONTAL_CLASS = 'terminal-action codicon-split-horizontal'; public static readonly VERTICAL_CLASS = 'terminal-action codicon-split-vertical'; constructor( id: string, label: string, @ITerminalService private readonly _terminalService: ITerminalService, - @ICommandService private readonly commandService: ICommandService, - @IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService + @ICommandService private readonly _commandService: ICommandService, + @IWorkspaceContextService private readonly _workspaceContextService: IWorkspaceContextService ) { super(id, label, SplitTerminalAction.HORIZONTAL_CLASS); } public async run(event?: any): Promise { - const instance = this._terminalService.getActiveInstance(); - if (!instance) { - return Promise.resolve(undefined); - } - const cwd = await getCwdForSplit(this._terminalService.configHelper, instance, this.workspaceContextService.getWorkspace().folders, this.commandService); - if (cwd === undefined) { - return undefined; - } - this._terminalService.splitInstance(instance, { cwd }); - return this._terminalService.showPanel(true); + await this._terminalService.doWithActiveInstance(async t => { + const cwd = await getCwdForSplit(this._terminalService.configHelper, t, this._workspaceContextService.getWorkspace().folders, this._commandService); + if (cwd === undefined) { + return undefined; + } + this._terminalService.splitInstance(t, { cwd }); + return this._terminalService.showPanel(true); + }); } } export class SplitInActiveWorkspaceTerminalAction extends Action { public static readonly ID = TERMINAL_COMMAND_ID.SPLIT_IN_ACTIVE_WORKSPACE; - public static readonly LABEL = nls.localize('workbench.action.terminal.splitInActiveWorkspace', "Split Terminal (In Active Workspace)"); + public static readonly LABEL = localize('workbench.action.terminal.splitInActiveWorkspace', "Split Terminal (In Active Workspace)"); constructor( id: string, label: string, @@ -316,208 +259,20 @@ export class SplitInActiveWorkspaceTerminalAction extends Action { super(id, label); } - public async run(event?: any): Promise { - const instance = this._terminalService.getActiveInstance(); - if (!instance) { - return Promise.resolve(undefined); - } - const cwd = await getCwdForSplit(this._terminalService.configHelper, instance); - this._terminalService.splitInstance(instance, { cwd }); - return this._terminalService.showPanel(true); - } -} - -export class FocusPreviousPaneTerminalAction extends Action { - public static readonly ID = TERMINAL_COMMAND_ID.FOCUS_PREVIOUS_PANE; - public static readonly LABEL = nls.localize('workbench.action.terminal.focusPreviousPane', "Focus Previous Pane"); - - constructor( - id: string, label: string, - @ITerminalService private readonly _terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - const tab = this._terminalService.getActiveTab(); - if (!tab) { - return Promise.resolve(undefined); - } - tab.focusPreviousPane(); - return this._terminalService.showPanel(true); - } -} - -export class FocusNextPaneTerminalAction extends Action { - public static readonly ID = TERMINAL_COMMAND_ID.FOCUS_NEXT_PANE; - public static readonly LABEL = nls.localize('workbench.action.terminal.focusNextPane', "Focus Next Pane"); - - constructor( - id: string, label: string, - @ITerminalService private readonly _terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - const tab = this._terminalService.getActiveTab(); - if (!tab) { - return Promise.resolve(undefined); - } - tab.focusNextPane(); - return this._terminalService.showPanel(true); - } -} - -export abstract class BaseFocusDirectionTerminalAction extends Action { - constructor( - id: string, label: string, - private _direction: Direction, - @ITerminalService private readonly _terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - const tab = this._terminalService.getActiveTab(); - if (tab) { - tab.resizePane(this._direction); - } - return Promise.resolve(undefined); - } -} - -export class ResizePaneLeftTerminalAction extends BaseFocusDirectionTerminalAction { - public static readonly ID = TERMINAL_COMMAND_ID.RESIZE_PANE_LEFT; - public static readonly LABEL = nls.localize('workbench.action.terminal.resizePaneLeft', "Resize Pane Left"); - - constructor( - id: string, label: string, - @ITerminalService readonly terminalService: ITerminalService - ) { - super(id, label, Direction.Left, terminalService); - } -} - -export class ResizePaneRightTerminalAction extends BaseFocusDirectionTerminalAction { - public static readonly ID = TERMINAL_COMMAND_ID.RESIZE_PANE_RIGHT; - public static readonly LABEL = nls.localize('workbench.action.terminal.resizePaneRight', "Resize Pane Right"); - - constructor( - id: string, label: string, - @ITerminalService readonly terminalService: ITerminalService - ) { - super(id, label, Direction.Right, terminalService); - } -} - -export class ResizePaneUpTerminalAction extends BaseFocusDirectionTerminalAction { - public static readonly ID = TERMINAL_COMMAND_ID.RESIZE_PANE_UP; - public static readonly LABEL = nls.localize('workbench.action.terminal.resizePaneUp', "Resize Pane Up"); - - constructor( - id: string, label: string, - @ITerminalService readonly terminalService: ITerminalService - ) { - super(id, label, Direction.Up, terminalService); - } -} - -export class ResizePaneDownTerminalAction extends BaseFocusDirectionTerminalAction { - public static readonly ID = TERMINAL_COMMAND_ID.RESIZE_PANE_DOWN; - public static readonly LABEL = nls.localize('workbench.action.terminal.resizePaneDown', "Resize Pane Down"); - - constructor( - id: string, label: string, - @ITerminalService readonly terminalService: ITerminalService - ) { - super(id, label, Direction.Down, terminalService); - } -} - -export class FocusActiveTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.FOCUS; - public static readonly LABEL = nls.localize('workbench.action.terminal.focus', "Focus Terminal"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - const instance = this.terminalService.getActiveOrCreateInstance(); - if (!instance) { - return Promise.resolve(undefined); - } - this.terminalService.setActiveInstance(instance); - return this.terminalService.showPanel(true); - } -} - -export class FocusNextTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.FOCUS_NEXT; - public static readonly LABEL = nls.localize('workbench.action.terminal.focusNext', "Focus Next Terminal"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - this.terminalService.setActiveTabToNext(); - return this.terminalService.showPanel(true); - } -} - -export class FocusPreviousTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.FOCUS_PREVIOUS; - public static readonly LABEL = nls.localize('workbench.action.terminal.focusPrevious', "Focus Previous Terminal"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - this.terminalService.setActiveTabToPrevious(); - return this.terminalService.showPanel(true); + async run() { + await this._terminalService.doWithActiveInstance(async t => { + const cwd = await getCwdForSplit(this._terminalService.configHelper, t); + this._terminalService.splitInstance(t, { cwd }); + await this._terminalService.showPanel(true); + }); } } export class TerminalPasteAction extends Action { public static readonly ID = TERMINAL_COMMAND_ID.PASTE; - public static readonly LABEL = nls.localize('workbench.action.terminal.paste', "Paste into Active Terminal"); - public static readonly SHORT_LABEL = nls.localize('workbench.action.terminal.paste.short', "Paste"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public async run(event?: any): Promise { - const instance = this.terminalService.getActiveOrCreateInstance(); - if (instance) { - await instance.paste(); - } - } -} - -export class SelectDefaultShellWindowsTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.SELECT_DEFAULT_SHELL; - public static readonly LABEL = nls.localize('workbench.action.terminal.selectDefaultShell', "Select Default Shell"); + public static readonly LABEL = localize('workbench.action.terminal.paste', "Paste into Active Terminal"); + public static readonly SHORT_LABEL = localize('workbench.action.terminal.paste.short', "Paste"); constructor( id: string, label: string, @@ -526,92 +281,36 @@ export class SelectDefaultShellWindowsTerminalAction extends Action { super(id, label); } - public run(event?: any): Promise { - return this._terminalService.selectDefaultShell(); + async run() { + this._terminalService.getActiveOrCreateInstance()?.paste(); } } -export class RunSelectedTextInTerminalAction extends Action { +export class SelectDefaultShellWindowsTerminalAction extends Action { - public static readonly ID = TERMINAL_COMMAND_ID.RUN_SELECTED_TEXT; - public static readonly LABEL = nls.localize('workbench.action.terminal.runSelectedText', "Run Selected Text In Active Terminal"); + public static readonly ID = TERMINAL_COMMAND_ID.SELECT_DEFAULT_SHELL; + public static readonly LABEL = localize('workbench.action.terminal.selectDefaultShell', "Select Default Shell"); constructor( id: string, label: string, - @ICodeEditorService private readonly codeEditorService: ICodeEditorService, - @ITerminalService private readonly terminalService: ITerminalService + @ITerminalService private readonly _terminalService: ITerminalService ) { super(id, label); } - public run(event?: any): Promise { - const instance = this.terminalService.getActiveOrCreateInstance(); - if (!instance) { - return Promise.resolve(undefined); - } - let editor = this.codeEditorService.getFocusedCodeEditor(); - if (!editor || !editor.hasModel()) { - return Promise.resolve(undefined); - } - let selection = editor.getSelection(); - let text: string; - if (selection.isEmpty()) { - text = editor.getModel().getLineContent(selection.selectionStartLineNumber).trim(); - } else { - const endOfLinePreference = isWindows ? EndOfLinePreference.LF : EndOfLinePreference.CRLF; - text = editor.getModel().getValueInRange(selection, endOfLinePreference); - } - instance.sendText(text, true); - return this.terminalService.showPanel(); - } -} - -export class RunActiveFileInTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.RUN_ACTIVE_FILE; - public static readonly LABEL = nls.localize('workbench.action.terminal.runActiveFile', "Run Active File In Active Terminal"); - - constructor( - id: string, label: string, - @ICodeEditorService private readonly codeEditorService: ICodeEditorService, - @ITerminalService private readonly terminalService: ITerminalService, - @INotificationService private readonly notificationService: INotificationService - ) { - super(id, label); - } - - public async run(event?: any): Promise { - const instance = this.terminalService.getActiveOrCreateInstance(); - if (!instance) { - return Promise.resolve(undefined); - } - await instance.processReady; - - const editor = this.codeEditorService.getActiveCodeEditor(); - if (!editor || !editor.hasModel()) { - return Promise.resolve(undefined); - } - const uri = editor.getModel().uri; - if (uri.scheme !== 'file') { - this.notificationService.warn(nls.localize('workbench.action.terminal.runActiveFile.noFile', 'Only files on disk can be run in the terminal')); - return Promise.resolve(undefined); - } - - // TODO: Convert this to ctrl+c, ctrl+v for pwsh? - const path = await this.terminalService.preparePathForTerminalAsync(uri.fsPath, instance.shellLaunchConfig.executable, instance.title, instance.shellType); - instance.sendText(path, true); - return this.terminalService.showPanel(); + async run() { + this._terminalService.selectDefaultShell(); } } export class SwitchTerminalAction extends Action { public static readonly ID = TERMINAL_COMMAND_ID.SWITCH_TERMINAL; - public static readonly LABEL = nls.localize('workbench.action.terminal.switchTerminal', "Switch Terminal"); + public static readonly LABEL = localize('workbench.action.terminal.switchTerminal', "Switch Terminal"); constructor( id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService + @ITerminalService private readonly _terminalService: ITerminalService ) { super(id, label, 'terminal-action switch-terminal'); } @@ -621,16 +320,16 @@ export class SwitchTerminalAction extends Action { return Promise.resolve(null); } if (item === SwitchTerminalActionViewItem.SEPARATOR) { - this.terminalService.refreshActiveTab(); + this._terminalService.refreshActiveTab(); return Promise.resolve(null); } if (item === SelectDefaultShellWindowsTerminalAction.LABEL) { - this.terminalService.refreshActiveTab(); - return this.terminalService.selectDefaultShell(); + this._terminalService.refreshActiveTab(); + return this._terminalService.selectDefaultShell(); } const selectedTabIndex = parseInt(item.split(':')[0], 10) - 1; - this.terminalService.setActiveTabByIndex(selectedTabIndex); - return this.terminalService.showPanel(true); + this._terminalService.setActiveTabByIndex(selectedTabIndex); + return this._terminalService.showPanel(true); } } @@ -640,29 +339,29 @@ export class SwitchTerminalActionViewItem extends SelectActionViewItem { constructor( action: IAction, - @ITerminalService private readonly terminalService: ITerminalService, - @IThemeService private readonly themeService: IThemeService, + @ITerminalService private readonly _terminalService: ITerminalService, + @IThemeService private readonly _themeService: IThemeService, @IContextViewService contextViewService: IContextViewService ) { - super(null, action, getTerminalSelectOpenItems(terminalService), terminalService.activeTabIndex, contextViewService, { ariaLabel: nls.localize('terminals', 'Open Terminals.') }); + super(null, action, getTerminalSelectOpenItems(_terminalService), _terminalService.activeTabIndex, contextViewService, { ariaLabel: localize('terminals', 'Open Terminals.') }); - this._register(terminalService.onInstancesChanged(this._updateItems, this)); - this._register(terminalService.onActiveTabChanged(this._updateItems, this)); - this._register(terminalService.onInstanceTitleChanged(this._updateItems, this)); - this._register(terminalService.onTabDisposed(this._updateItems, this)); - this._register(attachSelectBoxStyler(this.selectBox, themeService)); + this._register(_terminalService.onInstancesChanged(this._updateItems, this)); + this._register(_terminalService.onActiveTabChanged(this._updateItems, this)); + this._register(_terminalService.onInstanceTitleChanged(this._updateItems, this)); + this._register(_terminalService.onTabDisposed(this._updateItems, this)); + this._register(attachSelectBoxStyler(this.selectBox, _themeService)); } render(container: HTMLElement): void { super.render(container); addClass(container, 'switch-terminal'); - this._register(attachStylerCallback(this.themeService, { selectBorder }, colors => { + this._register(attachStylerCallback(this._themeService, { selectBorder }, colors => { container.style.borderColor = colors.selectBorder ? `${colors.selectBorder}` : ''; })); } private _updateItems(): void { - this.setOptions(getTerminalSelectOpenItems(this.terminalService), this.terminalService.activeTabIndex); + this.setOptions(getTerminalSelectOpenItems(this._terminalService), this._terminalService.activeTabIndex); } } @@ -673,583 +372,899 @@ function getTerminalSelectOpenItems(terminalService: ITerminalService): ISelectO return items; } -export class ScrollDownTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.SCROLL_DOWN_LINE; - public static readonly LABEL = nls.localize('workbench.action.terminal.scrollDown', "Scroll Down (Line)"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - const terminalInstance = this.terminalService.getActiveInstance(); - if (terminalInstance) { - terminalInstance.scrollDownLine(); - } - return Promise.resolve(undefined); - } -} - -export class ScrollDownPageTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.SCROLL_DOWN_PAGE; - public static readonly LABEL = nls.localize('workbench.action.terminal.scrollDownPage', "Scroll Down (Page)"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - const terminalInstance = this.terminalService.getActiveInstance(); - if (terminalInstance) { - terminalInstance.scrollDownPage(); - } - return Promise.resolve(undefined); - } -} - -export class ScrollToBottomTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.SCROLL_TO_BOTTOM; - public static readonly LABEL = nls.localize('workbench.action.terminal.scrollToBottom', "Scroll to Bottom"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - const terminalInstance = this.terminalService.getActiveInstance(); - if (terminalInstance) { - terminalInstance.scrollToBottom(); - } - return Promise.resolve(undefined); - } -} - -export class ScrollUpTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.SCROLL_UP_LINE; - public static readonly LABEL = nls.localize('workbench.action.terminal.scrollUp', "Scroll Up (Line)"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - const terminalInstance = this.terminalService.getActiveInstance(); - if (terminalInstance) { - terminalInstance.scrollUpLine(); - } - return Promise.resolve(undefined); - } -} - -export class ScrollUpPageTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.SCROLL_UP_PAGE; - public static readonly LABEL = nls.localize('workbench.action.terminal.scrollUpPage', "Scroll Up (Page)"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - const terminalInstance = this.terminalService.getActiveInstance(); - if (terminalInstance) { - terminalInstance.scrollUpPage(); - } - return Promise.resolve(undefined); - } -} - -export class ScrollToTopTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.SCROLL_TO_TOP; - public static readonly LABEL = nls.localize('workbench.action.terminal.scrollToTop', "Scroll to Top"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - const terminalInstance = this.terminalService.getActiveInstance(); - if (terminalInstance) { - terminalInstance.scrollToTop(); - } - return Promise.resolve(undefined); - } -} - -export class NavigationModeExitTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.NAVIGATION_MODE_EXIT; - public static readonly LABEL = nls.localize('workbench.action.terminal.navigationModeExit', "Exit Navigation Mode"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - const terminalInstance = this.terminalService.getActiveInstance(); - if (terminalInstance && terminalInstance.navigationMode) { - terminalInstance.navigationMode.exitNavigationMode(); - } - return Promise.resolve(undefined); - } -} - - - -export class NavigationModeFocusPreviousTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.NAVIGATION_MODE_FOCUS_PREVIOUS; - public static readonly LABEL = nls.localize('workbench.action.terminal.navigationModeFocusPrevious', "Focus Previous Line (Navigation Mode)"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - const terminalInstance = this.terminalService.getActiveInstance(); - if (terminalInstance && terminalInstance.navigationMode) { - terminalInstance.navigationMode.focusPreviousLine(); - } - return Promise.resolve(undefined); - } -} - -export class NavigationModeFocusNextTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.NAVIGATION_MODE_FOCUS_NEXT; - public static readonly LABEL = nls.localize('workbench.action.terminal.navigationModeFocusNext', "Focus Next Line (Navigation Mode)"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - const terminalInstance = this.terminalService.getActiveInstance(); - if (terminalInstance && terminalInstance.navigationMode) { - terminalInstance.navigationMode.focusNextLine(); - } - return Promise.resolve(undefined); - } -} - export class ClearTerminalAction extends Action { public static readonly ID = TERMINAL_COMMAND_ID.CLEAR; - public static readonly LABEL = nls.localize('workbench.action.terminal.clear', "Clear"); + public static readonly LABEL = localize('workbench.action.terminal.clear', "Clear"); constructor( id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService + @ITerminalService private readonly _terminalService: ITerminalService ) { super(id, label); } - public run(event?: any): Promise { - const terminalInstance = this.terminalService.getActiveInstance(); - if (terminalInstance) { - terminalInstance.clear(); - terminalInstance.focus(); - } - return Promise.resolve(undefined); - } -} - -export class ClearSelectionTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.CLEAR_SELECTION; - public static readonly LABEL = nls.localize('workbench.action.terminal.clearSelection', "Clear Selection"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(event?: any): Promise { - const terminalInstance = this.terminalService.getActiveInstance(); - if (terminalInstance && terminalInstance.hasSelection()) { - terminalInstance.clearSelection(); - } - return Promise.resolve(undefined); - } -} - -export class ManageWorkspaceShellPermissionsTerminalCommand extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.MANAGE_WORKSPACE_SHELL_PERMISSIONS; - public static readonly LABEL = nls.localize('workbench.action.terminal.manageWorkspaceShellPermissions', "Manage Workspace Shell Permissions"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public async run(event?: any): Promise { - await this.terminalService.manageWorkspaceShellPermissions(); - } -} - -export class RenameTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.RENAME; - public static readonly LABEL = nls.localize('workbench.action.terminal.rename', "Rename"); - - constructor( - id: string, label: string, - @IQuickInputService protected quickInputService: IQuickInputService, - @ITerminalService protected terminalService: ITerminalService - ) { - super(id, label); - } - - public async run(): Promise { - const terminalInstance = this.terminalService.getActiveInstance(); - if (!terminalInstance) { - return Promise.resolve(undefined); - } - const name = await this.quickInputService.input({ - value: terminalInstance.title, - prompt: nls.localize('workbench.action.terminal.rename.prompt', "Enter terminal name"), + async run() { + this._terminalService.doWithActiveInstance(t => { + t.clear(); + t.focus(); }); - if (name) { - terminalInstance.setTitle(name, TitleEventSource.Api); + } +} + +export function registerTerminalActions() { + const category = TERMINAL_ACTION_CATEGORY; + + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.NEW_IN_ACTIVE_WORKSPACE, + title: localize('workbench.action.terminal.newInActiveWorkspace', "Create New Integrated Terminal (In Active Workspace)"), + f1: true, + category + }); } - } -} -export class RenameWithArgTerminalAction extends Action2 { - public static readonly ID = TERMINAL_COMMAND_ID.RENAME_WITH_ARG; - public static readonly LABEL = nls.localize('workbench.action.terminal.renameWithArg', "Rename the Currently Active Terminal"); - public static readonly NAME_ARG_LABEL = nls.localize('workbench.action.terminal.renameWithArg.name', "The new name for the terminal"); - - public run( - accessor: ServicesAccessor, - args?: { name?: string } - ): void { - const notificationService = accessor.get(INotificationService); - const terminalInstance = accessor.get(ITerminalService).getActiveInstance(); - - if (!terminalInstance) { - notificationService.warn(nls.localize('workbench.action.terminal.renameWithArg.noTerminal', "No active terminal to rename")); - return; + async run(accessor: ServicesAccessor) { + const terminalService = accessor.get(ITerminalService); + const instance = terminalService.createTerminal(undefined); + if (!instance) { + return; + } + terminalService.setActiveInstance(instance); + await terminalService.showPanel(true); } - - if (!args || !args.name) { - notificationService.warn(nls.localize('workbench.action.terminal.renameWithArg.noName', "No name argument provided")); - return; + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.FOCUS_PREVIOUS_PANE, + title: localize('workbench.action.terminal.focusPreviousPane', "Focus Previous Pane"), + f1: true, + category, + keybinding: { + primary: KeyMod.Alt | KeyCode.LeftArrow, + secondary: [KeyMod.Alt | KeyCode.UpArrow], + mac: { + primary: KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.LeftArrow, + secondary: [KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.UpArrow] + }, + when: KEYBINDING_CONTEXT_TERMINAL_FOCUS, + weight: KeybindingWeight.WorkbenchContrib + } + }); } - - terminalInstance.setTitle(args.name, TitleEventSource.Api); - } -} - -export class FocusTerminalFindWidgetAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.FIND_WIDGET_FOCUS; - public static readonly LABEL = nls.localize('workbench.action.terminal.focusFindWidget', "Focus Find Widget"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(): Promise { - return this.terminalService.focusFindWidget(); - } -} - -export class HideTerminalFindWidgetAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.FIND_WIDGET_HIDE; - public static readonly LABEL = nls.localize('workbench.action.terminal.hideFindWidget', "Hide Find Widget"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(): Promise { - return Promise.resolve(this.terminalService.hideFindWidget()); - } -} - -export class QuickAccessTerminalAction extends Action { - - public static readonly ID = TERMINAL_COMMAND_ID.QUICK_OPEN_TERM; - public static readonly LABEL = nls.localize('quickAccessTerminal', "Switch Active Terminal"); - - constructor( - id: string, - label: string, - @IQuickInputService private readonly quickInputService: IQuickInputService - ) { - super(id, label); - } - - async run(): Promise { - this.quickInputService.quickAccess.show(TerminalQuickAccessProvider.PREFIX); - } -} - -export class ScrollToPreviousCommandAction extends Action { - public static readonly ID = TERMINAL_COMMAND_ID.SCROLL_TO_PREVIOUS_COMMAND; - public static readonly LABEL = nls.localize('workbench.action.terminal.scrollToPreviousCommand', "Scroll To Previous Command"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(): Promise { - const instance = this.terminalService.getActiveInstance(); - if (instance && instance.commandTracker) { - instance.commandTracker.scrollToPreviousCommand(); - instance.focus(); + async run(accessor: ServicesAccessor) { + const terminalService = accessor.get(ITerminalService); + terminalService.getActiveTab()?.focusPreviousPane(); + await terminalService.showPanel(true); } - return Promise.resolve(undefined); - } -} - -export class ScrollToNextCommandAction extends Action { - public static readonly ID = TERMINAL_COMMAND_ID.SCROLL_TO_NEXT_COMMAND; - public static readonly LABEL = nls.localize('workbench.action.terminal.scrollToNextCommand', "Scroll To Next Command"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(): Promise { - const instance = this.terminalService.getActiveInstance(); - if (instance && instance.commandTracker) { - instance.commandTracker.scrollToNextCommand(); - instance.focus(); + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.FOCUS_NEXT_PANE, + title: localize('workbench.action.terminal.focusNextPane', "Focus Next Pane"), + f1: true, + category, + keybinding: { + primary: KeyMod.Alt | KeyCode.RightArrow, + secondary: [KeyMod.Alt | KeyCode.DownArrow], + mac: { + primary: KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.RightArrow, + secondary: [KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.DownArrow] + }, + when: KEYBINDING_CONTEXT_TERMINAL_FOCUS, + weight: KeybindingWeight.WorkbenchContrib + } + }); } - return Promise.resolve(undefined); - } -} - -export class SelectToPreviousCommandAction extends Action { - public static readonly ID = TERMINAL_COMMAND_ID.SELECT_TO_PREVIOUS_COMMAND; - public static readonly LABEL = nls.localize('workbench.action.terminal.selectToPreviousCommand', "Select To Previous Command"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(): Promise { - const instance = this.terminalService.getActiveInstance(); - if (instance && instance.commandTracker) { - instance.commandTracker.selectToPreviousCommand(); - instance.focus(); + async run(accessor: ServicesAccessor) { + const terminalService = accessor.get(ITerminalService); + terminalService.getActiveTab()?.focusNextPane(); + await terminalService.showPanel(true); } - return Promise.resolve(undefined); - } -} - -export class SelectToNextCommandAction extends Action { - public static readonly ID = TERMINAL_COMMAND_ID.SELECT_TO_NEXT_COMMAND; - public static readonly LABEL = nls.localize('workbench.action.terminal.selectToNextCommand', "Select To Next Command"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(): Promise { - const instance = this.terminalService.getActiveInstance(); - if (instance && instance.commandTracker) { - instance.commandTracker.selectToNextCommand(); - instance.focus(); + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.RESIZE_PANE_LEFT, + title: localize('workbench.action.terminal.resizePaneLeft', "Resize Pane Left"), + f1: true, + category, + keybinding: { + linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.LeftArrow }, + mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.LeftArrow }, + when: KEYBINDING_CONTEXT_TERMINAL_FOCUS, + weight: KeybindingWeight.WorkbenchContrib + } + }); } - return Promise.resolve(undefined); - } -} - -export class SelectToPreviousLineAction extends Action { - public static readonly ID = TERMINAL_COMMAND_ID.SELECT_TO_PREVIOUS_LINE; - public static readonly LABEL = nls.localize('workbench.action.terminal.selectToPreviousLine', "Select To Previous Line"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(): Promise { - const instance = this.terminalService.getActiveInstance(); - if (instance && instance.commandTracker) { - instance.commandTracker.selectToPreviousLine(); - instance.focus(); + async run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).getActiveTab()?.resizePane(Direction.Left); } - return Promise.resolve(undefined); - } -} - -export class SelectToNextLineAction extends Action { - public static readonly ID = TERMINAL_COMMAND_ID.SELECT_TO_NEXT_LINE; - public static readonly LABEL = nls.localize('workbench.action.terminal.selectToNextLine', "Select To Next Line"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(): Promise { - const instance = this.terminalService.getActiveInstance(); - if (instance && instance.commandTracker) { - instance.commandTracker.selectToNextLine(); - instance.focus(); + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.RESIZE_PANE_RIGHT, + title: localize('workbench.action.terminal.resizePaneRight', "Resize Pane Right"), + f1: true, + category, + keybinding: { + linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.RightArrow }, + mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.RightArrow }, + when: KEYBINDING_CONTEXT_TERMINAL_FOCUS, + weight: KeybindingWeight.WorkbenchContrib + } + }); } - return Promise.resolve(undefined); - } -} - - -export class ToggleEscapeSequenceLoggingAction extends Action { - public static readonly ID = TERMINAL_COMMAND_ID.TOGGLE_ESCAPE_SEQUENCE_LOGGING; - public static readonly LABEL = nls.localize('workbench.action.terminal.toggleEscapeSequenceLogging', "Toggle Escape Sequence Logging"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(): Promise { - const instance = this.terminalService.getActiveInstance(); - if (instance) { - instance.toggleEscapeSequenceLogging(); + async run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).getActiveTab()?.resizePane(Direction.Right); } - return Promise.resolve(undefined); - } -} - -abstract class ToggleFindOptionCommand extends Action { - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - protected abstract runInner(state: FindReplaceState): void; - - public run(): Promise { - const state = this.terminalService.getFindState(); - this.runInner(state); - return Promise.resolve(undefined); - } -} - -export class ToggleRegexCommand extends ToggleFindOptionCommand { - public static readonly ID = TERMINAL_COMMAND_ID.TOGGLE_FIND_REGEX; - public static readonly LABEL = nls.localize('workbench.action.terminal.toggleFindRegex', "Toggle find using regex"); - - protected runInner(state: FindReplaceState): void { - state.change({ isRegex: !state.isRegex }, false); - } -} - -export class ToggleWholeWordCommand extends ToggleFindOptionCommand { - public static readonly ID = TERMINAL_COMMAND_ID.TOGGLE_FIND_WHOLE_WORD; - public static readonly LABEL = nls.localize('workbench.action.terminal.toggleFindWholeWord', "Toggle find using whole word"); - - protected runInner(state: FindReplaceState): void { - state.change({ wholeWord: !state.wholeWord }, false); - } -} - -export class ToggleCaseSensitiveCommand extends ToggleFindOptionCommand { - public static readonly ID = TERMINAL_COMMAND_ID.TOGGLE_FIND_CASE_SENSITIVE; - public static readonly LABEL = nls.localize('workbench.action.terminal.toggleFindCaseSensitive', "Toggle find using case sensitive"); - - protected runInner(state: FindReplaceState): void { - state.change({ matchCase: !state.matchCase }, false); - } -} - -export class FindNext extends Action { - public static readonly ID = TERMINAL_COMMAND_ID.FIND_NEXT; - public static readonly LABEL = nls.localize('workbench.action.terminal.findNext', "Find next"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(): Promise { - this.terminalService.findNext(); - return Promise.resolve(undefined); - } -} - -export class FindPrevious extends Action { - public static readonly ID = TERMINAL_COMMAND_ID.FIND_PREVIOUS; - public static readonly LABEL = nls.localize('workbench.action.terminal.findPrevious', "Find previous"); - - constructor( - id: string, label: string, - @ITerminalService private readonly terminalService: ITerminalService - ) { - super(id, label); - } - - public run(): Promise { - this.terminalService.findPrevious(); - return Promise.resolve(undefined); - } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.RESIZE_PANE_UP, + title: localize('workbench.action.terminal.resizePaneUp', "Resize Pane Up"), + f1: true, + category, + keybinding: { + mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.UpArrow }, + when: KEYBINDING_CONTEXT_TERMINAL_FOCUS, + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + async run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).getActiveTab()?.resizePane(Direction.Up); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.RESIZE_PANE_DOWN, + title: localize('workbench.action.terminal.resizePaneDown', "Resize Pane Down"), + f1: true, + category, + keybinding: { + mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.DownArrow }, + when: KEYBINDING_CONTEXT_TERMINAL_FOCUS, + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + async run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).getActiveTab()?.resizePane(Direction.Down); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.FOCUS, + title: localize('workbench.action.terminal.focus', "Focus Terminal"), + f1: true, + category + }); + } + async run(accessor: ServicesAccessor) { + const terminalService = accessor.get(ITerminalService); + const instance = terminalService.getActiveOrCreateInstance(); + if (!instance) { + return; + } + terminalService.setActiveInstance(instance); + return terminalService.showPanel(true); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.FOCUS_NEXT, + title: localize('workbench.action.terminal.focusNext', "Focus Next Terminal"), + f1: true, + category + }); + } + async run(accessor: ServicesAccessor) { + const terminalService = accessor.get(ITerminalService); + terminalService.setActiveTabToNext(); + await terminalService.showPanel(true); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.FOCUS_PREVIOUS, + title: localize('workbench.action.terminal.focusPrevious', "Focus Previous Terminal"), + f1: true, + category + }); + } + async run(accessor: ServicesAccessor) { + const terminalService = accessor.get(ITerminalService); + terminalService.setActiveTabToPrevious(); + await terminalService.showPanel(true); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.RUN_SELECTED_TEXT, + title: localize('workbench.action.terminal.runSelectedText', "Run Selected Text In Active Terminal"), + f1: true, + category + }); + } + async run(accessor: ServicesAccessor) { + const terminalService = accessor.get(ITerminalService); + const codeEditorService = accessor.get(ICodeEditorService); + + const instance = terminalService.getActiveOrCreateInstance(); + let editor = codeEditorService.getFocusedCodeEditor(); + if (!editor || !editor.hasModel()) { + return; + } + let selection = editor.getSelection(); + let text: string; + if (selection.isEmpty()) { + text = editor.getModel().getLineContent(selection.selectionStartLineNumber).trim(); + } else { + const endOfLinePreference = isWindows ? EndOfLinePreference.LF : EndOfLinePreference.CRLF; + text = editor.getModel().getValueInRange(selection, endOfLinePreference); + } + instance.sendText(text, true); + return terminalService.showPanel(); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.RUN_ACTIVE_FILE, + title: localize('workbench.action.terminal.runActiveFile', "Run Active File In Active Terminal"), + f1: true, + category + }); + } + async run(accessor: ServicesAccessor) { + const terminalService = accessor.get(ITerminalService); + const codeEditorService = accessor.get(ICodeEditorService); + const notificationService = accessor.get(INotificationService); + + const instance = terminalService.getActiveOrCreateInstance(); + await instance.processReady; + + const editor = codeEditorService.getActiveCodeEditor(); + if (!editor || !editor.hasModel()) { + return; + } + + const uri = editor.getModel().uri; + if (uri.scheme !== 'file') { + notificationService.warn(localize('workbench.action.terminal.runActiveFile.noFile', 'Only files on disk can be run in the terminal')); + return; + } + + // TODO: Convert this to ctrl+c, ctrl+v for pwsh? + const path = await terminalService.preparePathForTerminalAsync(uri.fsPath, instance.shellLaunchConfig.executable, instance.title, instance.shellType); + instance.sendText(path, true); + return terminalService.showPanel(); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.SCROLL_DOWN_LINE, + title: localize('workbench.action.terminal.scrollDown', "Scroll Down (Line)"), + f1: true, + category, + keybinding: { + primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageDown, + linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.DownArrow }, + when: KEYBINDING_CONTEXT_TERMINAL_FOCUS, + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).getActiveInstance()?.scrollDownLine(); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.SCROLL_DOWN_PAGE, + title: localize('workbench.action.terminal.scrollDownPage', "Scroll Down (Page)"), + f1: true, + category, + keybinding: { + primary: KeyMod.Shift | KeyCode.PageDown, + mac: { primary: KeyCode.PageDown }, + when: KEYBINDING_CONTEXT_TERMINAL_FOCUS, + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).getActiveInstance()?.scrollDownPage(); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.SCROLL_TO_BOTTOM, + title: localize('workbench.action.terminal.scrollToBottom', "Scroll to Bottom"), + f1: true, + category, + keybinding: { + primary: KeyMod.CtrlCmd | KeyCode.End, + linux: { primary: KeyMod.Shift | KeyCode.End }, + when: KEYBINDING_CONTEXT_TERMINAL_FOCUS, + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).getActiveInstance()?.scrollToBottom(); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.SCROLL_UP_LINE, + title: localize('workbench.action.terminal.scrollUp', "Scroll Up (Line)"), + f1: true, + category, + keybinding: { + primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageUp, + linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.UpArrow }, + when: KEYBINDING_CONTEXT_TERMINAL_FOCUS, + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).getActiveInstance()?.scrollUpLine(); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.SCROLL_UP_PAGE, + title: localize('workbench.action.terminal.scrollUpPage', "Scroll Up (Page)"), + f1: true, + category, + keybinding: { + primary: KeyMod.Shift | KeyCode.PageUp, + mac: { primary: KeyCode.PageUp }, + when: KEYBINDING_CONTEXT_TERMINAL_FOCUS, + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).getActiveInstance()?.scrollUpPage(); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.SCROLL_TO_TOP, + title: localize('workbench.action.terminal.scrollToTop', "Scroll to Top"), + f1: true, + category, + keybinding: { + primary: KeyMod.CtrlCmd | KeyCode.Home, + linux: { primary: KeyMod.Shift | KeyCode.Home }, + when: KEYBINDING_CONTEXT_TERMINAL_FOCUS, + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).getActiveInstance()?.scrollToTop(); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.NAVIGATION_MODE_EXIT, + title: localize('workbench.action.terminal.navigationModeExit', "Exit Navigation Mode"), + f1: true, + category, + keybinding: { + primary: KeyCode.Escape, + when: ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, CONTEXT_ACCESSIBILITY_MODE_ENABLED), + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).getActiveInstance()?.navigationMode?.focusPreviousLine(); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.NAVIGATION_MODE_FOCUS_PREVIOUS, + title: localize('workbench.action.terminal.navigationModeFocusPrevious', "Focus Previous Line (Navigation Mode)"), + f1: true, + category, + keybinding: { + primary: KeyMod.CtrlCmd | KeyCode.UpArrow, + when: ContextKeyExpr.or( + ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, CONTEXT_ACCESSIBILITY_MODE_ENABLED), + ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, CONTEXT_ACCESSIBILITY_MODE_ENABLED) + ), + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).getActiveInstance()?.navigationMode?.focusPreviousLine(); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.NAVIGATION_MODE_FOCUS_NEXT, + title: localize('workbench.action.terminal.navigationModeFocusNext', "Focus Next Line (Navigation Mode)"), + f1: true, + category, + keybinding: { + primary: KeyMod.CtrlCmd | KeyCode.DownArrow, + when: ContextKeyExpr.or( + ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, CONTEXT_ACCESSIBILITY_MODE_ENABLED), + ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, CONTEXT_ACCESSIBILITY_MODE_ENABLED) + ), + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).getActiveInstance()?.navigationMode?.focusNextLine(); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.CLEAR_SELECTION, + title: localize('workbench.action.terminal.clearSelection', "Clear Selection"), + f1: true, + category, + keybinding: { + primary: KeyCode.Escape, + when: ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_NOT_VISIBLE), + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + const terminalInstance = accessor.get(ITerminalService).getActiveInstance(); + if (terminalInstance && terminalInstance.hasSelection()) { + terminalInstance.clearSelection(); + } + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.MANAGE_WORKSPACE_SHELL_PERMISSIONS, + title: localize('workbench.action.terminal.manageWorkspaceShellPermissions', "Manage Workspace Shell Permissions"), + f1: true, + category + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).manageWorkspaceShellPermissions(); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.RENAME, + title: localize('workbench.action.terminal.rename', "Rename"), + f1: true, + category + }); + } + async run(accessor: ServicesAccessor) { + await accessor.get(ITerminalService).doWithActiveInstance(async t => { + const name = await accessor.get(IQuickInputService).input({ + value: t.title, + prompt: localize('workbench.action.terminal.rename.prompt', "Enter terminal name"), + }); + if (name) { + t.setTitle(name, TitleEventSource.Api); + } + }); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.FIND_WIDGET_FOCUS, + title: localize('workbench.action.terminal.focusFindWidget', "Focus Find Widget"), + f1: true, + category, + keybinding: { + primary: KeyMod.CtrlCmd | KeyCode.KEY_F, + when: ContextKeyExpr.or(KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED, KEYBINDING_CONTEXT_TERMINAL_FOCUS), + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).focusFindWidget(); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.FIND_WIDGET_HIDE, + title: localize('workbench.action.terminal.hideFindWidget', "Hide Find Widget"), + f1: true, + category, + keybinding: { + primary: KeyCode.Escape, + secondary: [KeyMod.Shift | KeyCode.Escape], + when: ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE), + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).hideFindWidget(); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.QUICK_OPEN_TERM, + title: localize('quickAccessTerminal', "Switch Active Terminal"), + f1: true, + category + }); + } + run(accessor: ServicesAccessor) { + accessor.get(IQuickInputService).quickAccess.show(TerminalQuickAccessProvider.PREFIX); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.SCROLL_TO_PREVIOUS_COMMAND, + title: localize('workbench.action.terminal.scrollToPreviousCommand', "Scroll To Previous Command"), + f1: true, + category, + keybinding: { + mac: { primary: KeyMod.CtrlCmd | KeyCode.UpArrow }, + when: ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()), + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).doWithActiveInstance(t => { + t.commandTracker?.scrollToPreviousCommand(); + t.focus(); + }); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.SCROLL_TO_NEXT_COMMAND, + title: localize('workbench.action.terminal.scrollToNextCommand', "Scroll To Next Command"), + f1: true, + category, + keybinding: { + mac: { primary: KeyMod.CtrlCmd | KeyCode.DownArrow }, + when: ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()), + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).doWithActiveInstance(t => { + t.commandTracker?.scrollToNextCommand(); + t.focus(); + }); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.SELECT_TO_PREVIOUS_COMMAND, + title: localize('workbench.action.terminal.selectToPreviousCommand', "Select To Previous Command"), + f1: true, + category, + keybinding: { + mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.UpArrow }, + when: KEYBINDING_CONTEXT_TERMINAL_FOCUS, + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).doWithActiveInstance(t => { + t.commandTracker?.selectToPreviousCommand(); + t.focus(); + }); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.SELECT_TO_NEXT_COMMAND, + title: localize('workbench.action.terminal.selectToNextCommand', "Select To Next Command"), + f1: true, + category, + keybinding: { + mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.DownArrow }, + when: KEYBINDING_CONTEXT_TERMINAL_FOCUS, + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).doWithActiveInstance(t => { + t.commandTracker?.selectToNextCommand(); + t.focus(); + }); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.SELECT_TO_PREVIOUS_LINE, + title: localize('workbench.action.terminal.selectToPreviousLine', "Select To Previous Line"), + f1: true, + category + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).doWithActiveInstance(t => { + t.commandTracker?.selectToPreviousLine(); + t.focus(); + }); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.SELECT_TO_NEXT_LINE, + title: localize('workbench.action.terminal.selectToNextLine', "Select To Next Line"), + f1: true, + category + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).doWithActiveInstance(t => { + t.commandTracker?.selectToNextLine(); + t.focus(); + }); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.TOGGLE_ESCAPE_SEQUENCE_LOGGING, + title: localize('workbench.action.terminal.toggleEscapeSequenceLogging', "Toggle Escape Sequence Logging"), + f1: true, + category + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).getActiveInstance()?.toggleEscapeSequenceLogging(); + } + }); + registerAction2(class extends Action2 { + constructor() { + const title = localize('workbench.action.terminal.sendSequence', "Send Custom Sequence To Terminal"); + super({ + id: TERMINAL_COMMAND_ID.SEND_SEQUENCE, + title, + category, + description: { + description: title, + args: [{ + name: 'args', + schema: { + type: 'object', + required: ['text'], + properties: { + text: { type: 'string' } + }, + } + }] + } + }); + } + run(accessor: ServicesAccessor, args?: { text?: string }) { + terminalSendSequenceCommand(accessor, args); + } + }); + registerAction2(class extends Action2 { + constructor() { + const title = localize('workbench.action.terminal.newWithCwd', "Create New Integrated Terminal Starting in a Custom Working Directory"); + super({ + id: TERMINAL_COMMAND_ID.NEW_WITH_CWD, + title, + category, + description: { + description: title, + args: [{ + name: 'args', + schema: { + type: 'object', + required: ['cwd'], + properties: { + cwd: { + description: localize('workbench.action.terminal.newWithCwd.cwd', "The directory to start the terminal at"), + type: 'string' + } + }, + } + }] + } + }); + } + async run(accessor: ServicesAccessor, args?: { cwd?: string }) { + const terminalService = accessor.get(ITerminalService); + const instance = terminalService.createTerminal({ cwd: args?.cwd }); + if (!instance) { + return; + } + terminalService.setActiveInstance(instance); + return terminalService.showPanel(true); + } + }); + registerAction2(class extends Action2 { + constructor() { + const title = localize('workbench.action.terminal.renameWithArg', "Rename the Currently Active Terminal"); + super({ + id: TERMINAL_COMMAND_ID.RENAME_WITH_ARG, + title, + category, + description: { + description: title, + args: [{ + name: 'args', + schema: { + type: 'object', + required: ['name'], + properties: { + name: { + description: localize('workbench.action.terminal.renameWithArg.name', "The new name for the terminal"), + type: 'string', + minLength: 1 + } + } + } + }] + } + }); + } + run(accessor: ServicesAccessor, args?: { name?: string }) { + const notificationService = accessor.get(INotificationService); + if (!args?.name) { + notificationService.warn(localize('workbench.action.terminal.renameWithArg.noName', "No name argument provided")); + return; + } + accessor.get(ITerminalService).getActiveInstance()?.setTitle(args.name, TitleEventSource.Api); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.TOGGLE_FIND_REGEX, + title: localize('workbench.action.terminal.toggleFindRegex', "Toggle find using regex"), + f1: true, + category, + keybinding: { + primary: KeyMod.Alt | KeyCode.KEY_R, + mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_R }, + when: ContextKeyExpr.or(KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED), + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + const state = accessor.get(ITerminalService).getFindState(); + state.change({ isRegex: !state.isRegex }, false); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.TOGGLE_FIND_WHOLE_WORD, + title: localize('workbench.action.terminal.toggleFindWholeWord', "Toggle find using whole word"), + f1: true, + category, + keybinding: { + primary: KeyMod.Alt | KeyCode.KEY_W, + mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_W }, + when: ContextKeyExpr.or(KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED), + weight: KeybindingWeight.WorkbenchContrib + }, + }); + } + run(accessor: ServicesAccessor) { + const state = accessor.get(ITerminalService).getFindState(); + state.change({ wholeWord: !state.wholeWord }, false); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.TOGGLE_FIND_CASE_SENSITIVE, + title: localize('workbench.action.terminal.toggleFindCaseSensitive', "Toggle find using case sensitive"), + f1: true, + category, + keybinding: { + primary: KeyMod.Alt | KeyCode.KEY_C, + mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_C }, + when: ContextKeyExpr.or(KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED), + weight: KeybindingWeight.WorkbenchContrib + } + }); + } + run(accessor: ServicesAccessor) { + const state = accessor.get(ITerminalService).getFindState(); + state.change({ matchCase: !state.matchCase }, false); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.FIND_NEXT, + title: localize('workbench.action.terminal.findNext', "Find next"), + f1: true, + category, + keybinding: [ + { + primary: KeyCode.F3, + mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_G, secondary: [KeyCode.F3] }, + when: ContextKeyExpr.or(KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED), + weight: KeybindingWeight.WorkbenchContrib + }, + { + primary: KeyMod.Shift | KeyCode.Enter, + when: KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED, + weight: KeybindingWeight.WorkbenchContrib + } + ] + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).findNext(); + } + }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TERMINAL_COMMAND_ID.FIND_PREVIOUS, + title: localize('workbench.action.terminal.findPrevious', "Find previous"), + f1: true, + category, + keybinding: [ + { + primary: KeyMod.Shift | KeyCode.F3, + mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_G, secondary: [KeyMod.Shift | KeyCode.F3] }, + when: ContextKeyExpr.or(KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED), + weight: KeybindingWeight.WorkbenchContrib + }, + { + primary: KeyCode.Enter, + when: KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED, + weight: KeybindingWeight.WorkbenchContrib + } + ] + }); + } + run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).findPrevious(); + } + }); } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 3c191048690..8f22139ccb7 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -25,7 +25,7 @@ import { activeContrastBorder, scrollbarSliderActiveBackground, scrollbarSliderB import { ICssStyleCollector, IColorTheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService'; import { PANEL_BACKGROUND, SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme'; import { TerminalWidgetManager } from 'vs/workbench/contrib/terminal/browser/terminalWidgetManager'; -import { IShellLaunchConfig, ITerminalDimensions, ITerminalProcessManager, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, NEVER_MEASURE_RENDER_TIME_STORAGE_KEY, ProcessState, TERMINAL_VIEW_ID, IWindowsShellHelper, SHELL_PATH_INVALID_EXIT_CODE, SHELL_PATH_DIRECTORY_EXIT_CODE, SHELL_CWD_INVALID_EXIT_CODE, KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, INavigationMode, TitleEventSource, TERMINAL_COMMAND_ID, LEGACY_CONSOLE_MODE_EXIT_CODE } from 'vs/workbench/contrib/terminal/common/terminal'; +import { IShellLaunchConfig, ITerminalDimensions, ITerminalProcessManager, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, NEVER_MEASURE_RENDER_TIME_STORAGE_KEY, ProcessState, TERMINAL_VIEW_ID, IWindowsShellHelper, SHELL_PATH_INVALID_EXIT_CODE, SHELL_PATH_DIRECTORY_EXIT_CODE, SHELL_CWD_INVALID_EXIT_CODE, KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, INavigationMode, TitleEventSource, LEGACY_CONSOLE_MODE_EXIT_CODE, DEFAULT_COMMANDS_TO_SKIP_SHELL } from 'vs/workbench/contrib/terminal/common/terminal'; import { ansiColorIdentifiers, TERMINAL_BACKGROUND_COLOR, TERMINAL_CURSOR_BACKGROUND_COLOR, TERMINAL_CURSOR_FOREGROUND_COLOR, TERMINAL_FOREGROUND_COLOR, TERMINAL_SELECTION_BACKGROUND_COLOR } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry'; import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminalConfigHelper'; import { TerminalLinkHandler } from 'vs/workbench/contrib/terminal/browser/terminalLinkHandler'; @@ -47,125 +47,6 @@ import { IViewsService, IViewDescriptorService, ViewContainerLocation } from 'vs const SLOW_CANVAS_RENDER_THRESHOLD = 50; const NUMBER_OF_FRAMES_TO_MEASURE = 20; -export const DEFAULT_COMMANDS_TO_SKIP_SHELL: string[] = [ - TERMINAL_COMMAND_ID.CLEAR_SELECTION, - TERMINAL_COMMAND_ID.CLEAR, - TERMINAL_COMMAND_ID.COPY_SELECTION, - TERMINAL_COMMAND_ID.DELETE_TO_LINE_START, - TERMINAL_COMMAND_ID.DELETE_WORD_LEFT, - TERMINAL_COMMAND_ID.DELETE_WORD_RIGHT, - TERMINAL_COMMAND_ID.FIND_WIDGET_FOCUS, - TERMINAL_COMMAND_ID.FIND_WIDGET_HIDE, - TERMINAL_COMMAND_ID.FIND_NEXT, - TERMINAL_COMMAND_ID.FIND_PREVIOUS, - TERMINAL_COMMAND_ID.TOGGLE_FIND_REGEX, - TERMINAL_COMMAND_ID.TOGGLE_FIND_WHOLE_WORD, - TERMINAL_COMMAND_ID.TOGGLE_FIND_CASE_SENSITIVE, - TERMINAL_COMMAND_ID.FOCUS_NEXT_PANE, - TERMINAL_COMMAND_ID.FOCUS_NEXT, - TERMINAL_COMMAND_ID.FOCUS_PREVIOUS_PANE, - TERMINAL_COMMAND_ID.FOCUS_PREVIOUS, - TERMINAL_COMMAND_ID.FOCUS, - TERMINAL_COMMAND_ID.KILL, - TERMINAL_COMMAND_ID.MOVE_TO_LINE_END, - TERMINAL_COMMAND_ID.MOVE_TO_LINE_START, - TERMINAL_COMMAND_ID.NEW_IN_ACTIVE_WORKSPACE, - TERMINAL_COMMAND_ID.NEW, - TERMINAL_COMMAND_ID.PASTE, - TERMINAL_COMMAND_ID.RESIZE_PANE_DOWN, - TERMINAL_COMMAND_ID.RESIZE_PANE_LEFT, - TERMINAL_COMMAND_ID.RESIZE_PANE_RIGHT, - TERMINAL_COMMAND_ID.RESIZE_PANE_UP, - TERMINAL_COMMAND_ID.RUN_ACTIVE_FILE, - TERMINAL_COMMAND_ID.RUN_SELECTED_TEXT, - TERMINAL_COMMAND_ID.SCROLL_DOWN_LINE, - TERMINAL_COMMAND_ID.SCROLL_DOWN_PAGE, - TERMINAL_COMMAND_ID.SCROLL_TO_BOTTOM, - TERMINAL_COMMAND_ID.SCROLL_TO_NEXT_COMMAND, - TERMINAL_COMMAND_ID.SCROLL_TO_PREVIOUS_COMMAND, - TERMINAL_COMMAND_ID.SCROLL_TO_TOP, - TERMINAL_COMMAND_ID.SCROLL_UP_LINE, - TERMINAL_COMMAND_ID.SCROLL_UP_PAGE, - TERMINAL_COMMAND_ID.SEND_SEQUENCE, - TERMINAL_COMMAND_ID.SELECT_ALL, - TERMINAL_COMMAND_ID.SELECT_TO_NEXT_COMMAND, - TERMINAL_COMMAND_ID.SELECT_TO_NEXT_LINE, - TERMINAL_COMMAND_ID.SELECT_TO_PREVIOUS_COMMAND, - TERMINAL_COMMAND_ID.SELECT_TO_PREVIOUS_LINE, - TERMINAL_COMMAND_ID.SPLIT_IN_ACTIVE_WORKSPACE, - TERMINAL_COMMAND_ID.SPLIT, - TERMINAL_COMMAND_ID.TOGGLE, - TERMINAL_COMMAND_ID.NAVIGATION_MODE_EXIT, - TERMINAL_COMMAND_ID.NAVIGATION_MODE_FOCUS_NEXT, - TERMINAL_COMMAND_ID.NAVIGATION_MODE_FOCUS_PREVIOUS, - 'editor.action.toggleTabFocusMode', - 'workbench.action.quickOpen', - 'workbench.action.quickOpenPreviousEditor', - 'workbench.action.showCommands', - 'workbench.action.tasks.build', - 'workbench.action.tasks.restartTask', - 'workbench.action.tasks.runTask', - 'workbench.action.tasks.reRunTask', - 'workbench.action.tasks.showLog', - 'workbench.action.tasks.showTasks', - 'workbench.action.tasks.terminate', - 'workbench.action.tasks.test', - 'workbench.action.toggleFullScreen', - 'workbench.action.terminal.focusAtIndex1', - 'workbench.action.terminal.focusAtIndex2', - 'workbench.action.terminal.focusAtIndex3', - 'workbench.action.terminal.focusAtIndex4', - 'workbench.action.terminal.focusAtIndex5', - 'workbench.action.terminal.focusAtIndex6', - 'workbench.action.terminal.focusAtIndex7', - 'workbench.action.terminal.focusAtIndex8', - 'workbench.action.terminal.focusAtIndex9', - 'workbench.action.focusSecondEditorGroup', - 'workbench.action.focusThirdEditorGroup', - 'workbench.action.focusFourthEditorGroup', - 'workbench.action.focusFifthEditorGroup', - 'workbench.action.focusSixthEditorGroup', - 'workbench.action.focusSeventhEditorGroup', - 'workbench.action.focusEighthEditorGroup', - 'workbench.action.nextPanelView', - 'workbench.action.previousPanelView', - 'workbench.action.nextSideBarView', - 'workbench.action.previousSideBarView', - 'workbench.action.debug.start', - 'workbench.action.debug.stop', - 'workbench.action.debug.run', - 'workbench.action.debug.restart', - 'workbench.action.debug.continue', - 'workbench.action.debug.pause', - 'workbench.action.debug.stepInto', - 'workbench.action.debug.stepOut', - 'workbench.action.debug.stepOver', - 'workbench.action.nextEditor', - 'workbench.action.previousEditor', - 'workbench.action.nextEditorInGroup', - 'workbench.action.previousEditorInGroup', - 'workbench.action.openNextRecentlyUsedEditor', - 'workbench.action.openPreviousRecentlyUsedEditor', - 'workbench.action.openNextRecentlyUsedEditorInGroup', - 'workbench.action.openPreviousRecentlyUsedEditorInGroup', - 'workbench.action.quickOpenPreviousRecentlyUsedEditor', - 'workbench.action.quickOpenLeastRecentlyUsedEditor', - 'workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup', - 'workbench.action.quickOpenLeastRecentlyUsedEditorInGroup', - 'workbench.action.focusActiveEditorGroup', - 'workbench.action.focusFirstEditorGroup', - 'workbench.action.focusLastEditorGroup', - 'workbench.action.firstEditorInGroup', - 'workbench.action.lastEditorInGroup', - 'workbench.action.navigateUp', - 'workbench.action.navigateDown', - 'workbench.action.navigateRight', - 'workbench.action.navigateLeft', - 'workbench.action.togglePanel', - 'workbench.action.quickOpenView', - 'workbench.action.toggleMaximizedPanel' -]; - let xtermConstructor: Promise | undefined; interface ICanvasDimensions { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalService.ts b/src/vs/workbench/contrib/terminal/browser/terminalService.ts index 858a2bb7f5e..667b3ed88da 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalService.ts @@ -297,6 +297,13 @@ export class TerminalService implements ITerminalService { return tab.activeInstance; } + public doWithActiveInstance(callback: (terminal: ITerminalInstance) => T): T | void { + const instance = this.getActiveInstance(); + if (instance) { + return callback(instance); + } + } + public getInstanceFromId(terminalId: number): ITerminalInstance | undefined { let bgIndex = -1; this._backgroundedTerminalInstances.forEach((terminalInstance, i) => { diff --git a/src/vs/workbench/contrib/terminal/common/terminal.ts b/src/vs/workbench/contrib/terminal/common/terminal.ts index 41400261a91..dc2d844b8ae 100644 --- a/src/vs/workbench/contrib/terminal/common/terminal.ts +++ b/src/vs/workbench/contrib/terminal/common/terminal.ts @@ -484,3 +484,122 @@ export const enum TERMINAL_COMMAND_ID { NAVIGATION_MODE_FOCUS_NEXT = 'workbench.action.terminal.navigationModeFocusNext', NAVIGATION_MODE_FOCUS_PREVIOUS = 'workbench.action.terminal.navigationModeFocusPrevious' } + +export const DEFAULT_COMMANDS_TO_SKIP_SHELL: string[] = [ + TERMINAL_COMMAND_ID.CLEAR_SELECTION, + TERMINAL_COMMAND_ID.CLEAR, + TERMINAL_COMMAND_ID.COPY_SELECTION, + TERMINAL_COMMAND_ID.DELETE_TO_LINE_START, + TERMINAL_COMMAND_ID.DELETE_WORD_LEFT, + TERMINAL_COMMAND_ID.DELETE_WORD_RIGHT, + TERMINAL_COMMAND_ID.FIND_WIDGET_FOCUS, + TERMINAL_COMMAND_ID.FIND_WIDGET_HIDE, + TERMINAL_COMMAND_ID.FIND_NEXT, + TERMINAL_COMMAND_ID.FIND_PREVIOUS, + TERMINAL_COMMAND_ID.TOGGLE_FIND_REGEX, + TERMINAL_COMMAND_ID.TOGGLE_FIND_WHOLE_WORD, + TERMINAL_COMMAND_ID.TOGGLE_FIND_CASE_SENSITIVE, + TERMINAL_COMMAND_ID.FOCUS_NEXT_PANE, + TERMINAL_COMMAND_ID.FOCUS_NEXT, + TERMINAL_COMMAND_ID.FOCUS_PREVIOUS_PANE, + TERMINAL_COMMAND_ID.FOCUS_PREVIOUS, + TERMINAL_COMMAND_ID.FOCUS, + TERMINAL_COMMAND_ID.KILL, + TERMINAL_COMMAND_ID.MOVE_TO_LINE_END, + TERMINAL_COMMAND_ID.MOVE_TO_LINE_START, + TERMINAL_COMMAND_ID.NEW_IN_ACTIVE_WORKSPACE, + TERMINAL_COMMAND_ID.NEW, + TERMINAL_COMMAND_ID.PASTE, + TERMINAL_COMMAND_ID.RESIZE_PANE_DOWN, + TERMINAL_COMMAND_ID.RESIZE_PANE_LEFT, + TERMINAL_COMMAND_ID.RESIZE_PANE_RIGHT, + TERMINAL_COMMAND_ID.RESIZE_PANE_UP, + TERMINAL_COMMAND_ID.RUN_ACTIVE_FILE, + TERMINAL_COMMAND_ID.RUN_SELECTED_TEXT, + TERMINAL_COMMAND_ID.SCROLL_DOWN_LINE, + TERMINAL_COMMAND_ID.SCROLL_DOWN_PAGE, + TERMINAL_COMMAND_ID.SCROLL_TO_BOTTOM, + TERMINAL_COMMAND_ID.SCROLL_TO_NEXT_COMMAND, + TERMINAL_COMMAND_ID.SCROLL_TO_PREVIOUS_COMMAND, + TERMINAL_COMMAND_ID.SCROLL_TO_TOP, + TERMINAL_COMMAND_ID.SCROLL_UP_LINE, + TERMINAL_COMMAND_ID.SCROLL_UP_PAGE, + TERMINAL_COMMAND_ID.SEND_SEQUENCE, + TERMINAL_COMMAND_ID.SELECT_ALL, + TERMINAL_COMMAND_ID.SELECT_TO_NEXT_COMMAND, + TERMINAL_COMMAND_ID.SELECT_TO_NEXT_LINE, + TERMINAL_COMMAND_ID.SELECT_TO_PREVIOUS_COMMAND, + TERMINAL_COMMAND_ID.SELECT_TO_PREVIOUS_LINE, + TERMINAL_COMMAND_ID.SPLIT_IN_ACTIVE_WORKSPACE, + TERMINAL_COMMAND_ID.SPLIT, + TERMINAL_COMMAND_ID.TOGGLE, + TERMINAL_COMMAND_ID.NAVIGATION_MODE_EXIT, + TERMINAL_COMMAND_ID.NAVIGATION_MODE_FOCUS_NEXT, + TERMINAL_COMMAND_ID.NAVIGATION_MODE_FOCUS_PREVIOUS, + 'editor.action.toggleTabFocusMode', + 'workbench.action.quickOpen', + 'workbench.action.quickOpenPreviousEditor', + 'workbench.action.showCommands', + 'workbench.action.tasks.build', + 'workbench.action.tasks.restartTask', + 'workbench.action.tasks.runTask', + 'workbench.action.tasks.reRunTask', + 'workbench.action.tasks.showLog', + 'workbench.action.tasks.showTasks', + 'workbench.action.tasks.terminate', + 'workbench.action.tasks.test', + 'workbench.action.toggleFullScreen', + 'workbench.action.terminal.focusAtIndex1', + 'workbench.action.terminal.focusAtIndex2', + 'workbench.action.terminal.focusAtIndex3', + 'workbench.action.terminal.focusAtIndex4', + 'workbench.action.terminal.focusAtIndex5', + 'workbench.action.terminal.focusAtIndex6', + 'workbench.action.terminal.focusAtIndex7', + 'workbench.action.terminal.focusAtIndex8', + 'workbench.action.terminal.focusAtIndex9', + 'workbench.action.focusSecondEditorGroup', + 'workbench.action.focusThirdEditorGroup', + 'workbench.action.focusFourthEditorGroup', + 'workbench.action.focusFifthEditorGroup', + 'workbench.action.focusSixthEditorGroup', + 'workbench.action.focusSeventhEditorGroup', + 'workbench.action.focusEighthEditorGroup', + 'workbench.action.nextPanelView', + 'workbench.action.previousPanelView', + 'workbench.action.nextSideBarView', + 'workbench.action.previousSideBarView', + 'workbench.action.debug.start', + 'workbench.action.debug.stop', + 'workbench.action.debug.run', + 'workbench.action.debug.restart', + 'workbench.action.debug.continue', + 'workbench.action.debug.pause', + 'workbench.action.debug.stepInto', + 'workbench.action.debug.stepOut', + 'workbench.action.debug.stepOver', + 'workbench.action.nextEditor', + 'workbench.action.previousEditor', + 'workbench.action.nextEditorInGroup', + 'workbench.action.previousEditorInGroup', + 'workbench.action.openNextRecentlyUsedEditor', + 'workbench.action.openPreviousRecentlyUsedEditor', + 'workbench.action.openNextRecentlyUsedEditorInGroup', + 'workbench.action.openPreviousRecentlyUsedEditorInGroup', + 'workbench.action.quickOpenPreviousRecentlyUsedEditor', + 'workbench.action.quickOpenLeastRecentlyUsedEditor', + 'workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup', + 'workbench.action.quickOpenLeastRecentlyUsedEditorInGroup', + 'workbench.action.focusActiveEditorGroup', + 'workbench.action.focusFirstEditorGroup', + 'workbench.action.focusLastEditorGroup', + 'workbench.action.firstEditorInGroup', + 'workbench.action.lastEditorInGroup', + 'workbench.action.navigateUp', + 'workbench.action.navigateDown', + 'workbench.action.navigateRight', + 'workbench.action.navigateLeft', + 'workbench.action.togglePanel', + 'workbench.action.quickOpenView', + 'workbench.action.toggleMaximizedPanel' +]; diff --git a/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts b/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts new file mode 100644 index 00000000000..ee9846eb41c --- /dev/null +++ b/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts @@ -0,0 +1,340 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { IConfigurationNode } from 'vs/platform/configuration/common/configurationRegistry'; +import { localize } from 'vs/nls'; +import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions'; +import { DEFAULT_LETTER_SPACING, DEFAULT_LINE_HEIGHT, TerminalCursorStyle, DEFAULT_COMMANDS_TO_SKIP_SHELL } from 'vs/workbench/contrib/terminal/common/terminal'; +import { isMacintosh, isWindows, Platform } from 'vs/base/common/platform'; + +export const terminalConfiguration: IConfigurationNode = { + id: 'terminal', + order: 100, + title: localize('terminalIntegratedConfigurationTitle', "Integrated Terminal"), + type: 'object', + properties: { + 'terminal.integrated.automationShell.linux': { + markdownDescription: localize('terminal.integrated.automationShell.linux', "A path that when set will override {0} and ignore {1} values for automation-related terminal usage like tasks and debug.", '`terminal.integrated.shell.linux`', '`shellArgs`'), + type: ['string', 'null'], + default: null + }, + 'terminal.integrated.automationShell.osx': { + markdownDescription: localize('terminal.integrated.automationShell.osx', "A path that when set will override {0} and ignore {1} values for automation-related terminal usage like tasks and debug.", '`terminal.integrated.shell.osx`', '`shellArgs`'), + type: ['string', 'null'], + default: null + }, + 'terminal.integrated.automationShell.windows': { + markdownDescription: localize('terminal.integrated.automationShell.windows', "A path that when set will override {0} and ignore {1} values for automation-related terminal usage like tasks and debug.", '`terminal.integrated.shell.windows`', '`shellArgs`'), + type: ['string', 'null'], + default: null + }, + 'terminal.integrated.shellArgs.linux': { + markdownDescription: localize('terminal.integrated.shellArgs.linux', "The command line arguments to use when on the Linux terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), + type: 'array', + items: { + type: 'string' + }, + default: [] + }, + 'terminal.integrated.shellArgs.osx': { + markdownDescription: localize('terminal.integrated.shellArgs.osx', "The command line arguments to use when on the macOS terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), + type: 'array', + items: { + type: 'string' + }, + // Unlike on Linux, ~/.profile is not sourced when logging into a macOS session. This + // is the reason terminals on macOS typically run login shells by default which set up + // the environment. See http://unix.stackexchange.com/a/119675/115410 + default: ['-l'] + }, + 'terminal.integrated.shellArgs.windows': { + markdownDescription: localize('terminal.integrated.shellArgs.windows', "The command line arguments to use when on the Windows terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), + 'anyOf': [ + { + type: 'array', + items: { + type: 'string', + markdownDescription: localize('terminal.integrated.shellArgs.windows', "The command line arguments to use when on the Windows terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration).") + }, + }, + { + type: 'string', + markdownDescription: localize('terminal.integrated.shellArgs.windows.string', "The command line arguments in [command-line format](https://msdn.microsoft.com/en-au/08dfcab2-eb6e-49a4-80eb-87d4076c98c6) to use when on the Windows terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration).") + } + ], + default: [] + }, + 'terminal.integrated.macOptionIsMeta': { + description: localize('terminal.integrated.macOptionIsMeta', "Controls whether to treat the option key as the meta key in the terminal on macOS."), + type: 'boolean', + default: false + }, + 'terminal.integrated.macOptionClickForcesSelection': { + description: localize('terminal.integrated.macOptionClickForcesSelection', "Controls whether to force selection when using Option+click on macOS. This will force a regular (line) selection and disallow the use of column selection mode. This enables copying and pasting using the regular terminal selection, for example, when mouse mode is enabled in tmux."), + type: 'boolean', + default: false + }, + 'terminal.integrated.copyOnSelection': { + description: localize('terminal.integrated.copyOnSelection', "Controls whether text selected in the terminal will be copied to the clipboard."), + type: 'boolean', + default: false + }, + 'terminal.integrated.drawBoldTextInBrightColors': { + description: localize('terminal.integrated.drawBoldTextInBrightColors', "Controls whether bold text in the terminal will always use the \"bright\" ANSI color variant."), + type: 'boolean', + default: true + }, + 'terminal.integrated.fontFamily': { + markdownDescription: localize('terminal.integrated.fontFamily', "Controls the font family of the terminal, this defaults to `#editor.fontFamily#`'s value."), + type: 'string' + }, + // TODO: Support font ligatures + // 'terminal.integrated.fontLigatures': { + // 'description': localize('terminal.integrated.fontLigatures', "Controls whether font ligatures are enabled in the terminal."), + // 'type': 'boolean', + // 'default': false + // }, + 'terminal.integrated.fontSize': { + description: localize('terminal.integrated.fontSize', "Controls the font size in pixels of the terminal."), + type: 'number', + default: EDITOR_FONT_DEFAULTS.fontSize + }, + 'terminal.integrated.letterSpacing': { + description: localize('terminal.integrated.letterSpacing', "Controls the letter spacing of the terminal, this is an integer value which represents the amount of additional pixels to add between characters."), + type: 'number', + default: DEFAULT_LETTER_SPACING + }, + 'terminal.integrated.lineHeight': { + description: localize('terminal.integrated.lineHeight', "Controls the line height of the terminal, this number is multiplied by the terminal font size to get the actual line-height in pixels."), + type: 'number', + default: DEFAULT_LINE_HEIGHT + }, + 'terminal.integrated.minimumContrastRatio': { + markdownDescription: localize('terminal.integrated.minimumContrastRatio', "When set the foreground color of each cell will change to try meet the contrast ratio specified. Example values:\n\n- 1: The default, do nothing.\n- 4.5: [WCAG AA compliance (minimum)](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html).\n- 7: [WCAG AAA compliance (enhanced)](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast7.html).\n- 21: White on black or black on white."), + type: 'number', + default: 1 + }, + 'terminal.integrated.fastScrollSensitivity': { + markdownDescription: localize('terminal.integrated.fastScrollSensitivity', "Scrolling speed multiplier when pressing `Alt`."), + type: 'number', + default: 5 + }, + 'terminal.integrated.mouseWheelScrollSensitivity': { + markdownDescription: localize('terminal.integrated.mouseWheelScrollSensitivity', "A multiplier to be used on the `deltaY` of mouse wheel scroll events."), + type: 'number', + default: 1 + }, + 'terminal.integrated.fontWeight': { + type: 'string', + enum: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'], + description: localize('terminal.integrated.fontWeight', "The font weight to use within the terminal for non-bold text."), + default: 'normal' + }, + 'terminal.integrated.fontWeightBold': { + type: 'string', + enum: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'], + description: localize('terminal.integrated.fontWeightBold', "The font weight to use within the terminal for bold text."), + default: 'bold' + }, + 'terminal.integrated.cursorBlinking': { + description: localize('terminal.integrated.cursorBlinking', "Controls whether the terminal cursor blinks."), + type: 'boolean', + default: false + }, + 'terminal.integrated.cursorStyle': { + description: localize('terminal.integrated.cursorStyle', "Controls the style of terminal cursor."), + enum: [TerminalCursorStyle.BLOCK, TerminalCursorStyle.LINE, TerminalCursorStyle.UNDERLINE], + default: TerminalCursorStyle.BLOCK + }, + 'terminal.integrated.cursorWidth': { + markdownDescription: localize('terminal.integrated.cursorWidth', "Controls the width of the cursor when `#terminal.integrated.cursorStyle#` is set to `line`."), + type: 'number', + default: 1 + }, + 'terminal.integrated.scrollback': { + description: localize('terminal.integrated.scrollback', "Controls the maximum amount of lines the terminal keeps in its buffer."), + type: 'number', + default: 1000 + }, + 'terminal.integrated.detectLocale': { + markdownDescription: localize('terminal.integrated.detectLocale', "Controls whether to detect and set the `$LANG` environment variable to a UTF-8 compliant option since VS Code's terminal only supports UTF-8 encoded data coming from the shell."), + type: 'string', + enum: ['auto', 'off', 'on'], + markdownEnumDescriptions: [ + localize('terminal.integrated.detectLocale.auto', "Set the `$LANG` environment variable if the existing variable does not exist or it does not end in `'.UTF-8'`."), + localize('terminal.integrated.detectLocale.off', "Do not set the `$LANG` environment variable."), + localize('terminal.integrated.detectLocale.on', "Always set the `$LANG` environment variable.") + ], + default: 'auto' + }, + 'terminal.integrated.rendererType': { + type: 'string', + enum: ['auto', 'canvas', 'dom', 'experimentalWebgl'], + markdownEnumDescriptions: [ + localize('terminal.integrated.rendererType.auto', "Let VS Code guess which renderer to use."), + localize('terminal.integrated.rendererType.canvas', "Use the standard GPU/canvas-based renderer."), + localize('terminal.integrated.rendererType.dom', "Use the fallback DOM-based renderer."), + localize('terminal.integrated.rendererType.experimentalWebgl', "Use the experimental webgl-based renderer. Note that this has some [known issues](https://github.com/xtermjs/xterm.js/issues?q=is%3Aopen+is%3Aissue+label%3Aarea%2Faddon%2Fwebgl) and this will only be enabled for new terminals (not hot swappable like the other renderers).") + ], + default: 'auto', + description: localize('terminal.integrated.rendererType', "Controls how the terminal is rendered.") + }, + 'terminal.integrated.rightClickBehavior': { + type: 'string', + enum: ['default', 'copyPaste', 'paste', 'selectWord'], + enumDescriptions: [ + localize('terminal.integrated.rightClickBehavior.default', "Show the context menu."), + localize('terminal.integrated.rightClickBehavior.copyPaste', "Copy when there is a selection, otherwise paste."), + localize('terminal.integrated.rightClickBehavior.paste', "Paste on right click."), + localize('terminal.integrated.rightClickBehavior.selectWord', "Select the word under the cursor and show the context menu.") + ], + default: isMacintosh ? 'selectWord' : isWindows ? 'copyPaste' : 'default', + description: localize('terminal.integrated.rightClickBehavior', "Controls how terminal reacts to right click.") + }, + 'terminal.integrated.cwd': { + description: localize('terminal.integrated.cwd', "An explicit start path where the terminal will be launched, this is used as the current working directory (cwd) for the shell process. This may be particularly useful in workspace settings if the root directory is not a convenient cwd."), + type: 'string', + default: undefined + }, + 'terminal.integrated.confirmOnExit': { + description: localize('terminal.integrated.confirmOnExit', "Controls whether to confirm on exit if there are active terminal sessions."), + type: 'boolean', + default: false + }, + 'terminal.integrated.enableBell': { + description: localize('terminal.integrated.enableBell', "Controls whether the terminal bell is enabled."), + type: 'boolean', + default: false + }, + 'terminal.integrated.commandsToSkipShell': { + markdownDescription: localize('terminal.integrated.commandsToSkipShell', "A set of command IDs whose keybindings will not be sent to the shell and instead always be handled by Code. This allows the use of keybindings that would normally be consumed by the shell to act the same as when the terminal is not focused, for example ctrl+p to launch Quick Open.\nDefault Skipped Commands:\n\n{0}", DEFAULT_COMMANDS_TO_SKIP_SHELL.sort().map(command => `- ${command}`).join('\n')), + type: 'array', + items: { + type: 'string' + }, + default: [] + }, + 'terminal.integrated.allowChords': { + markdownDescription: localize('terminal.integrated.allowChords', "Whether or not to allow chord keybindings in the terminal. Note that when this is true and the keystroke results in a chord it will bypass `#terminal.integrated.commandsToSkipShell#`, setting this to false is particularly useful when you want ctrl+k to go to your shell (not VS Code)."), + type: 'boolean', + default: true + }, + 'terminal.integrated.allowMnemonics': { + markdownDescription: localize('terminal.integrated.allowMnemonics', "Whether to allow menubar mnemonics (eg. alt+f) to trigger the open the menubar. Note that this will cause all alt keystrokes will skip the shell when true. This does nothing on macOS."), + type: 'boolean', + default: false + }, + 'terminal.integrated.inheritEnv': { + markdownDescription: localize('terminal.integrated.inheritEnv', "Whether new shells should inherit their environment from VS Code. This is not supported on Windows."), + type: 'boolean', + default: true + }, + 'terminal.integrated.env.osx': { + markdownDescription: localize('terminal.integrated.env.osx', "Object with environment variables that will be added to the VS Code process to be used by the terminal on macOS. Set to `null` to delete the environment variable."), + type: 'object', + additionalProperties: { + type: ['string', 'null'] + }, + default: {} + }, + 'terminal.integrated.env.linux': { + markdownDescription: localize('terminal.integrated.env.linux', "Object with environment variables that will be added to the VS Code process to be used by the terminal on Linux. Set to `null` to delete the environment variable."), + type: 'object', + additionalProperties: { + type: ['string', 'null'] + }, + default: {} + }, + 'terminal.integrated.env.windows': { + markdownDescription: localize('terminal.integrated.env.windows', "Object with environment variables that will be added to the VS Code process to be used by the terminal on Windows. Set to `null` to delete the environment variable."), + type: 'object', + additionalProperties: { + type: ['string', 'null'] + }, + default: {} + }, + 'terminal.integrated.showExitAlert': { + description: localize('terminal.integrated.showExitAlert', "Controls whether to show the alert \"The terminal process terminated with exit code\" when exit code is non-zero."), + type: 'boolean', + default: true + }, + 'terminal.integrated.splitCwd': { + description: localize('terminal.integrated.splitCwd', "Controls the working directory a split terminal starts with."), + type: 'string', + enum: ['workspaceRoot', 'initial', 'inherited'], + enumDescriptions: [ + localize('terminal.integrated.splitCwd.workspaceRoot', "A new split terminal will use the workspace root as the working directory. In a multi-root workspace a choice for which root folder to use is offered."), + localize('terminal.integrated.splitCwd.initial', "A new split terminal will use the working directory that the parent terminal started with."), + localize('terminal.integrated.splitCwd.inherited', "On macOS and Linux, a new split terminal will use the working directory of the parent terminal. On Windows, this behaves the same as initial."), + ], + default: 'inherited' + }, + 'terminal.integrated.windowsEnableConpty': { + description: localize('terminal.integrated.windowsEnableConpty', "Whether to use ConPTY for Windows terminal process communication (requires Windows 10 build number 18309+). Winpty will be used if this is false."), + type: 'boolean', + default: true + }, + 'terminal.integrated.wordSeparators': { + description: localize('terminal.integrated.wordSeparators', "A string containing all characters to be considered word separators by the double click to select word feature."), + type: 'string', + default: ' ()[]{}\',"`' + }, + 'terminal.integrated.experimentalUseTitleEvent': { + description: localize('terminal.integrated.experimentalUseTitleEvent', "An experimental setting that will use the terminal title event for the dropdown title. This setting will only apply to new terminals."), + type: 'boolean', + default: false + }, + 'terminal.integrated.enableFileLinks': { + description: localize('terminal.integrated.enableFileLinks', "Whether to enable file links in the terminal. Links can be slow when working on a network drive in particular because each file link is verified against the file system."), + type: 'boolean', + default: true + }, + 'terminal.integrated.unicodeVersion': { + type: 'string', + enum: ['6', '11'], + enumDescriptions: [ + localize('terminal.integrated.unicodeVersion.six', "Version 6 of unicode, this is an older version which should work better on older systems."), + localize('terminal.integrated.unicodeVersion.eleven', "Version 11 of unicode, this version provides better support on modern systems that use modern versions of unicode.") + ], + default: '11', + description: localize('terminal.integrated.unicodeVersion', "Controls what version of unicode to use when evaluating the width of characters in the terminal. If you experience emoji or other wide characters not taking up the right amount of space or backspace either deleting too much or too little then you may want to try tweaking this setting.") + } + } +}; + +export function getTerminalShellConfiguration(getSystemShell?: (p: Platform) => string): IConfigurationNode { + return { + id: 'terminal', + order: 100, + title: localize('terminalIntegratedConfigurationTitle', "Integrated Terminal"), + type: 'object', + properties: { + 'terminal.integrated.shell.linux': { + markdownDescription: + getSystemShell + ? localize('terminal.integrated.shell.linux', "The path of the shell that the terminal uses on Linux (default: {0}). [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration).", getSystemShell(Platform.Linux)) + : localize('terminal.integrated.shell.linux.noDefault', "The path of the shell that the terminal uses on Linux. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), + type: ['string', 'null'], + default: null + }, + 'terminal.integrated.shell.osx': { + markdownDescription: + getSystemShell + ? localize('terminal.integrated.shell.osx', "The path of the shell that the terminal uses on macOS (default: {0}). [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration).", getSystemShell(Platform.Mac)) + : localize('terminal.integrated.shell.osx.noDefault', "The path of the shell that the terminal uses on macOS. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), + type: ['string', 'null'], + default: null + }, + 'terminal.integrated.shell.windows': { + markdownDescription: + getSystemShell + ? localize('terminal.integrated.shell.windows', "The path of the shell that the terminal uses on Windows (default: {0}). [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration).", getSystemShell(Platform.Windows)) + : localize('terminal.integrated.shell.windows.noDefault', "The path of the shell that the terminal uses on Windows. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), + type: ['string', 'null'], + default: null + } + } + }; +} diff --git a/src/vs/workbench/contrib/terminal/common/terminalShellConfig.ts b/src/vs/workbench/contrib/terminal/common/terminalShellConfig.ts deleted file mode 100644 index c08a6f47fe8..00000000000 --- a/src/vs/workbench/contrib/terminal/common/terminalShellConfig.ts +++ /dev/null @@ -1,45 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import * as nls from 'vs/nls'; -import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; -import { Registry } from 'vs/platform/registry/common/platform'; -import { Platform } from 'vs/base/common/platform'; - -export function registerShellConfiguration(getSystemShell?: (p: Platform) => string): void { - const configurationRegistry = Registry.as(Extensions.Configuration); - configurationRegistry.registerConfiguration({ - id: 'terminal', - order: 100, - title: nls.localize('terminalIntegratedConfigurationTitle', "Integrated Terminal"), - type: 'object', - properties: { - 'terminal.integrated.shell.linux': { - markdownDescription: - getSystemShell - ? nls.localize('terminal.integrated.shell.linux', "The path of the shell that the terminal uses on Linux (default: {0}). [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration).", getSystemShell(Platform.Linux)) - : nls.localize('terminal.integrated.shell.linux.noDefault', "The path of the shell that the terminal uses on Linux. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), - type: ['string', 'null'], - default: null - }, - 'terminal.integrated.shell.osx': { - markdownDescription: - getSystemShell - ? nls.localize('terminal.integrated.shell.osx', "The path of the shell that the terminal uses on macOS (default: {0}). [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration).", getSystemShell(Platform.Mac)) - : nls.localize('terminal.integrated.shell.osx.noDefault', "The path of the shell that the terminal uses on macOS. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), - type: ['string', 'null'], - default: null - }, - 'terminal.integrated.shell.windows': { - markdownDescription: - getSystemShell - ? nls.localize('terminal.integrated.shell.windows', "The path of the shell that the terminal uses on Windows (default: {0}). [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration).", getSystemShell(Platform.Windows)) - : nls.localize('terminal.integrated.shell.windows.noDefault', "The path of the shell that the terminal uses on Windows. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), - type: ['string', 'null'], - default: null - } - } - }); -} diff --git a/src/vs/workbench/contrib/terminal/electron-browser/terminal.contribution.ts b/src/vs/workbench/contrib/terminal/electron-browser/terminal.contribution.ts index f9dd46267ca..1721bf226a6 100644 --- a/src/vs/workbench/contrib/terminal/electron-browser/terminal.contribution.ts +++ b/src/vs/workbench/contrib/terminal/electron-browser/terminal.contribution.ts @@ -7,10 +7,18 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { ITerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminal'; import { TerminalInstanceService } from 'vs/workbench/contrib/terminal/electron-browser/terminalInstanceService'; import { getSystemShell } from 'vs/workbench/contrib/terminal/node/terminal'; -import { registerShellConfiguration } from 'vs/workbench/contrib/terminal/common/terminalShellConfig'; import { TerminalNativeService } from 'vs/workbench/contrib/terminal/electron-browser/terminalNativeService'; import { ITerminalNativeService } from 'vs/workbench/contrib/terminal/common/terminal'; +import { Registry } from 'vs/platform/registry/common/platform'; +import { IConfigurationRegistry, Extensions } from 'vs/platform/configuration/common/configurationRegistry'; +import { getTerminalShellConfiguration } from 'vs/workbench/contrib/terminal/common/terminalConfiguration'; -registerShellConfiguration(getSystemShell); +// This file contains additional desktop-only contributions on top of those in browser/ + +// Register services registerSingleton(ITerminalNativeService, TerminalNativeService, true); registerSingleton(ITerminalInstanceService, TerminalInstanceService, true); + +// Register configurations +const configurationRegistry = Registry.as(Extensions.Configuration); +configurationRegistry.registerConfiguration(getTerminalShellConfiguration(getSystemShell));