Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/cli/src/ui/contexts/KeypressContext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ describe('KeypressContext', () => {
);
});

it('should treat \\b as ctrl when OS is Windows_NT', async () => {
it('should NOT treat \\b as ctrl when OS is Windows_NT but WT_SESSION is absent', async () => {
vi.stubEnv('WT_SESSION', '');
vi.stubEnv('OS', 'Windows_NT');
const { keyHandler } = await setupKeypressTest();
Expand All @@ -492,7 +492,7 @@ describe('KeypressContext', () => {
expect(keyHandler).toHaveBeenCalledWith(
expect.objectContaining({
name: 'backspace',
ctrl: true,
ctrl: false,
}),
);
});
Expand Down
10 changes: 4 additions & 6 deletions packages/cli/src/ui/contexts/KeypressContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -654,12 +654,10 @@ function* emitKeys(
} else if (ch === '\b') {
// ctrl+h / ctrl+backspace (windows terminals send \x08 for ctrl+backspace)
name = 'backspace';
// In Windows environments, \b is sent for Ctrl+Backspace (standard backspace is translated to \x7f).
// We scope this to Windows/WT_SESSION to avoid breaking other unixes where \b is a plain backspace.
if (
typeof process !== 'undefined' &&
(process.env?.['OS'] === 'Windows_NT' || !!process.env?.['WT_SESSION'])
) {
// Windows Terminal sends \b for Ctrl+Backspace (regular backspace is \x7f).
// Only set ctrl=true for WT_SESSION (Windows Terminal); cmd.exe and PowerShell
// send \b for plain backspace so we must not treat them as Ctrl+Backspace.
if (typeof process !== 'undefined' && !!process.env?.['WT_SESSION']) {
ctrl = true;
}
alt = escaped;
Expand Down