Skip to content

Commit db88304

Browse files
dormouse-botclaude
andcommitted
Fix Linux CI failure and non-VS-Code Shift+Enter handler scope
- Mock IS_WINDOWS: true in the registry alert test so the Shift+Enter handler attaches on Linux CI, where IS_WINDOWS is otherwise false. - Only route VS Code workbench chords (F1, Ctrl+P, etc.) when the platform actually exposes runWorkbenchCommand, so non-VS-Code Windows hosts stop silently suppressing the browser default for those keys. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent c0b53d7 commit db88304

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

lib/src/lib/terminal-lifecycle.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ function createXtermHost(id: string): { terminal: Terminal; fit: FitAddon; eleme
117117
},
118118
});
119119

120-
// Only hosts that can run workbench commands (the VS Code adapter) opt in;
121-
// on every other platform runWorkbenchCommand is undefined, so the chords
122-
// stay in xterm exactly as before. Windows Shift+Enter is also normalized
123-
// here so terminal apps such as Codex see multiline input instead of Enter.
120+
// Two independent reasons to intercept keydown:
121+
// - Windows Shift+Enter needs LF normalization so terminal TUIs see a
122+
// newline instead of Enter (every Windows host, not just VS Code).
123+
// - Hosts that run workbench commands (the VS Code adapter) opt in to
124+
// forwarding F1/Ctrl+P/etc. up to the workbench; non-VS-Code hosts
125+
// leave those chords alone so the browser default still fires.
124126
if (IS_WINDOWS || getPlatform().runWorkbenchCommand) {
125127
terminal.attachCustomKeyEventHandler((event) => {
126128
const shiftEnterInput = shiftEnterInputForEvent(event, {
@@ -133,11 +135,13 @@ function createXtermHost(id: string): { terminal: Terminal; fit: FitAddon; eleme
133135
handleTerminalInput(id, terminal, shiftEnterInput);
134136
return false;
135137
}
138+
const runWorkbenchCommand = getPlatform().runWorkbenchCommand;
139+
if (!runWorkbenchCommand) return true;
136140
const command = vscodeWorkbenchCommandForKeydown(event, { isMac: IS_MAC });
137141
if (!command) return true;
138142
event.preventDefault();
139143
event.stopPropagation();
140-
getPlatform().runWorkbenchCommand?.(command);
144+
runWorkbenchCommand(command);
141145
return true;
142146
});
143147
}

lib/src/lib/terminal-registry.alert.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,11 @@ vi.mock('@xterm/xterm', () => {
103103
vi.mock('./platform', async () => {
104104
const actual = await vi.importActual<typeof import('./platform')>('./platform');
105105
const fakePlatform = new actual.FakePtyAdapter();
106+
// Force IS_WINDOWS so the Shift+Enter handler is attached regardless of
107+
// the host OS this test runs on (Linux CI evaluates it false at module load).
106108
return {
107109
...actual,
110+
IS_WINDOWS: true,
108111
getPlatform: () => fakePlatform,
109112
__fakePlatform: fakePlatform,
110113
};

0 commit comments

Comments
 (0)