@@ -13,7 +13,7 @@ import { ContextKeyExpr, type ContextKeyExpression } from '../../../../../platfo
1313import type { ServicesAccessor } from '../../../../../platform/instantiation/common/instantiation.js' ;
1414import { KeybindingsRegistry , KeybindingWeight , type IKeybindings } from '../../../../../platform/keybinding/common/keybindingsRegistry.js' ;
1515import { IQuickInputService } from '../../../../../platform/quickinput/common/quickInput.js' ;
16- import { GeneralShellType , WindowsShellType } from '../../../../../platform/terminal/common/terminal.js' ;
16+ import { GeneralShellType , TerminalSettingId , WindowsShellType } from '../../../../../platform/terminal/common/terminal.js' ;
1717import { IWorkspaceContextService } from '../../../../../platform/workspace/common/workspace.js' ;
1818import { IConfigurationResolverService } from '../../../../services/configurationResolver/common/configurationResolver.js' ;
1919import { IHistoryService } from '../../../../services/history/common/history.js' ;
@@ -133,6 +133,33 @@ if (isWindows) {
133133 } ) ;
134134}
135135
136+ // Map certain keybindings in pwsh to unused keys which get handled by PSReadLine handlers in the
137+ // shell integration script. This allows keystrokes that cannot be sent via VT sequences to work.
138+ // See https://github.com/microsoft/terminal/issues/879#issuecomment-497775007
139+ registerSendSequenceKeybinding ( '\x1b[24~a' , { // F12,a -> ctrl+space (MenuComplete)
140+ when : ContextKeyExpr . and ( TerminalContextKeys . focus , ContextKeyExpr . equals ( TerminalContextKeyStrings . ShellType , GeneralShellType . PowerShell ) , TerminalContextKeys . terminalShellIntegrationEnabled , ContextKeyExpr . equals ( `config.${ TerminalSettingId . EnableWin32InputMode } ` , true ) , CONTEXT_ACCESSIBILITY_MODE_ENABLED . negate ( ) ) ,
141+ primary : KeyMod . CtrlCmd | KeyCode . Space ,
142+ mac : { primary : KeyMod . WinCtrl | KeyCode . Space }
143+ } ) ;
144+ registerSendSequenceKeybinding ( '\x1b[24~b' , { // F12,b -> alt+space (SetMark)
145+ when : ContextKeyExpr . and ( TerminalContextKeys . focus , ContextKeyExpr . equals ( TerminalContextKeyStrings . ShellType , GeneralShellType . PowerShell ) , TerminalContextKeys . terminalShellIntegrationEnabled , ContextKeyExpr . equals ( `config.${ TerminalSettingId . EnableWin32InputMode } ` , true ) , CONTEXT_ACCESSIBILITY_MODE_ENABLED . negate ( ) ) ,
146+ primary : KeyMod . Alt | KeyCode . Space
147+ } ) ;
148+ registerSendSequenceKeybinding ( '\x1b[24~c' , { // F12,c -> shift+enter (AddLine)
149+ when : ContextKeyExpr . and ( TerminalContextKeys . focus , ContextKeyExpr . equals ( TerminalContextKeyStrings . ShellType , GeneralShellType . PowerShell ) , TerminalContextKeys . terminalShellIntegrationEnabled , ContextKeyExpr . equals ( `config.${ TerminalSettingId . EnableWin32InputMode } ` , true ) , CONTEXT_ACCESSIBILITY_MODE_ENABLED . negate ( ) ) ,
150+ primary : KeyMod . Shift | KeyCode . Enter
151+ } ) ;
152+ registerSendSequenceKeybinding ( '\x1b[24~d' , { // F12,d -> shift+end (SelectLine) - HACK: \x1b[1;2F is supposed to work but it doesn't
153+ when : ContextKeyExpr . and ( TerminalContextKeys . focus , ContextKeyExpr . equals ( TerminalContextKeyStrings . ShellType , GeneralShellType . PowerShell ) , TerminalContextKeys . terminalShellIntegrationEnabled , ContextKeyExpr . equals ( `config.${ TerminalSettingId . EnableWin32InputMode } ` , true ) , CONTEXT_ACCESSIBILITY_MODE_ENABLED . negate ( ) ) ,
154+ mac : { primary : KeyMod . Shift | KeyMod . CtrlCmd | KeyCode . RightArrow }
155+ } ) ;
156+
157+ // Always on pwsh keybindings
158+ registerSendSequenceKeybinding ( '\x1b[1;2H' , { // Shift+home
159+ when : ContextKeyExpr . and ( TerminalContextKeys . focus , ContextKeyExpr . equals ( TerminalContextKeyStrings . ShellType , GeneralShellType . PowerShell ) , ContextKeyExpr . equals ( `config.${ TerminalSettingId . EnableWin32InputMode } ` , true ) ) ,
160+ mac : { primary : KeyMod . Shift | KeyMod . CtrlCmd | KeyCode . LeftArrow }
161+ } ) ;
162+
136163// Map alt+arrow to ctrl+arrow to allow word navigation in most shells to just work with alt. This
137164// is non-standard behavior, but a lot of terminals act like this (see
138165// https://github.com/microsoft/vscode/issues/190629). Note that macOS uses different sequences here
0 commit comments