-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix Ctrl keybinding in terminal on Windows #1385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,8 @@ interface ShortcutMatchOptions { | |
|
|
||
| const TERMINAL_WORD_BACKWARD = "\u001bb"; | ||
| const TERMINAL_WORD_FORWARD = "\u001bf"; | ||
| const TERMINAL_WORD_BACKWARD_CTRL = "\u001b[1;5D"; | ||
| const TERMINAL_WORD_FORWARD_CTRL = "\u001b[1;5C"; | ||
| const TERMINAL_LINE_START = "\u0001"; | ||
| const TERMINAL_LINE_END = "\u0005"; | ||
|
|
||
|
|
@@ -269,8 +271,11 @@ export function terminalNavigationShortcutData( | |
| return null; | ||
| } | ||
|
|
||
| const moveWord = key === "arrowleft" ? TERMINAL_WORD_BACKWARD : TERMINAL_WORD_FORWARD; | ||
| const moveLine = key === "arrowleft" ? TERMINAL_LINE_START : TERMINAL_LINE_END; | ||
| const moveWord = | ||
| key === "arrowleft" ? TERMINAL_WORD_BACKWARD : TERMINAL_WORD_FORWARD; | ||
| const moveLine = | ||
| key === "arrowleft" ? TERMINAL_LINE_START : TERMINAL_LINE_END; | ||
| const moveWordCtrl = key === "arrowleft" ? TERMINAL_WORD_BACKWARD_CTRL : TERMINAL_WORD_FORWARD_CTRL; | ||
|
|
||
| if (isMacPlatform(platform)) { | ||
| if (event.altKey && !event.metaKey && !event.ctrlKey) { | ||
|
|
@@ -280,15 +285,12 @@ export function terminalNavigationShortcutData( | |
| return moveLine; | ||
| } | ||
| return null; | ||
| } else { | ||
|
|
||
| if (event.ctrlKey && !event.metaKey && !event.altKey) { | ||
| return moveWordCtrl; | ||
| } | ||
|
Comment on lines
274
to
+292
|
||
| return null; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alt+Arrow word movement removed on non-Mac platformsMedium Severity The refactored
Comment on lines
+288
to
+293
|
||
| } | ||
|
|
||
| if (event.ctrlKey && !event.metaKey && !event.altKey) { | ||
| return moveWord; | ||
| } | ||
|
|
||
| if (event.altKey && !event.metaKey && !event.ctrlKey) { | ||
| return moveWord; | ||
| } | ||
|
|
||
| return null; | ||
|
|
||
| } | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated expectations now use the CSI Ctrl+Arrow sequences for both Win32 and Linux, but the test name still reads as a single generic non-macOS case. Consider splitting this into explicit platform-specific assertions (e.g., Windows vs Linux) or adding a case for non-macOS
altKeybehavior (supported vs unsupported) so the intended cross-platform contract is clear.