From 3622cc4f4c05e3c53f739caf455c4cf754cc5459 Mon Sep 17 00:00:00 2001 From: haosenwang1018 <1293965075@qq.com> Date: Mon, 1 Jun 2026 17:47:03 +0800 Subject: [PATCH] fix(tui): recognize CSI-u Shift+Enter as newline --- .changeset/shift-enter-csi-u.md | 5 +++++ apps/kimi-code/src/tui/components/editor/custom-editor.ts | 1 + .../test/tui/components/editor/custom-editor.test.ts | 7 ++++--- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .changeset/shift-enter-csi-u.md diff --git a/.changeset/shift-enter-csi-u.md b/.changeset/shift-enter-csi-u.md new file mode 100644 index 00000000..9881b929 --- /dev/null +++ b/.changeset/shift-enter-csi-u.md @@ -0,0 +1,5 @@ +--- +"@moonshot-ai/kimi-code": patch +--- + +fix(tui): treat CSI-u Shift+Enter as an editor newline diff --git a/apps/kimi-code/src/tui/components/editor/custom-editor.ts b/apps/kimi-code/src/tui/components/editor/custom-editor.ts index 3ceff7a9..b1c574b4 100644 --- a/apps/kimi-code/src/tui/components/editor/custom-editor.ts +++ b/apps/kimi-code/src/tui/components/editor/custom-editor.ts @@ -87,6 +87,7 @@ function stripSgr(s: string): string { function getNewlineInput(data: string): string | undefined { if (data === '\n' || data === '\u001B\r' || data === '\u001B[13;2~') return data; + if (data === '\u001B[13;2u') return '\n'; if (matchesKey(data, Key.ctrl('j'))) return '\n'; return undefined; } diff --git a/apps/kimi-code/test/tui/components/editor/custom-editor.test.ts b/apps/kimi-code/test/tui/components/editor/custom-editor.test.ts index 6545af26..8deaa5eb 100644 --- a/apps/kimi-code/test/tui/components/editor/custom-editor.test.ts +++ b/apps/kimi-code/test/tui/components/editor/custom-editor.test.ts @@ -208,7 +208,7 @@ describe('CustomEditor paste marker expansion', () => { }); describe('CustomEditor shortcut telemetry hooks', () => { - it('reports newline shortcuts, including Ctrl-J, before delegating to the base editor', () => { + it('reports newline shortcuts, including Ctrl-J and CSI-u Shift+Enter, before delegating to the base editor', () => { const editor = makeEditor(); const onInsertNewline = vi.fn(); editor.onInsertNewline = onInsertNewline; @@ -216,9 +216,10 @@ describe('CustomEditor shortcut telemetry hooks', () => { editor.handleInput('a'); editor.handleInput('\n'); editor.handleInput('\u001B[106;5u'); + editor.handleInput('\u001B[13;2u'); - expect(onInsertNewline).toHaveBeenCalledTimes(2); - expect(editor.getText()).toBe('a\n\n'); + expect(onInsertNewline).toHaveBeenCalledTimes(3); + expect(editor.getText()).toBe('a\n\n\n'); }); it('reports undo shortcuts before delegating to the base editor', () => {