mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-06 15:39:41 +02:00
fix(terminal): swallow Shift+Enter keypress so it no longer submits
xterm runs the custom key handler for keypress too and drops Ctrl/Alt keypresses but not Shift-only ones, so the stray \r submitted the prompt after the newline. Swallow every event type for Shift/Ctrl+Enter and send only on keydown, in the primary pane and Pane B. Adds a static guard and a real xterm + Chromium browser test. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
9240493c43
commit
c9a5fdab00
@@ -0,0 +1,21 @@
|
||||
// @vitest-environment node
|
||||
// Regression guard: xterm runs the custom key handler for keydown AND keypress.
|
||||
// It discards a keypress carrying Ctrl/Alt but not one carrying only Shift, so
|
||||
// a handler that returns false for keydown alone lets Shift+Enter's keypress
|
||||
// through as a bare \r (submit). The Enter gate must therefore not be keyed on
|
||||
// ev.type === 'keydown'; only the send-key fetch is.
|
||||
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
const PUBLIC = join(new URL('.', import.meta.url).pathname, '../src/web/public');
|
||||
|
||||
describe.each(['terminal-ui.js', 'terminal-split.js'])('%s Shift/Ctrl+Enter handler', (file) => {
|
||||
const src = readFileSync(join(PUBLIC, file), 'utf8');
|
||||
|
||||
it('swallows every event type for Shift/Ctrl+Enter', () => {
|
||||
expect(src).toMatch(/ev\.key === 'Enter' && \(ev\.shiftKey \|\| ev\.ctrlKey\)\) \{/);
|
||||
expect(src).not.toMatch(/ev\.key === 'Enter' && \(ev\.shiftKey \|\| ev\.ctrlKey\) && ev\.type === 'keydown'/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user