diff --git a/.changeset/remove-duplicate-newline-handling.md b/.changeset/remove-duplicate-newline-handling.md new file mode 100644 index 0000000000..c2ef603df8 --- /dev/null +++ b/.changeset/remove-duplicate-newline-handling.md @@ -0,0 +1,5 @@ +--- +"@moonshot-ai/kimi-code": patch +--- + +Remove duplicate newline-shortcut handling from the prompt editor. 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 1fb28a0060..4616936928 100644 --- a/apps/kimi-code/src/tui/components/editor/custom-editor.ts +++ b/apps/kimi-code/src/tui/components/editor/custom-editor.ts @@ -114,12 +114,6 @@ function stripSgr(s: string): string { return s.replace(ANSI_SGR, ''); } -function getNewlineInput(data: string): string | undefined { - if (data === '\n' || data === '\u001B\r' || data === '\u001B[13;2~') return data; - if (matchesKey(data, Key.ctrl('j'))) return '\n'; - return undefined; -} - export class CustomEditor extends Editor { public onEscape?: () => void; /** @@ -137,7 +131,6 @@ export class CustomEditor extends Editor { /** Return `true` to consume Ctrl+T (the todo list had overflow to toggle); return `false`/`undefined` to fall through to the editor default. */ public onToggleTodoExpand?: () => boolean; public onUndo?: () => void; - public onInsertNewline?: () => void; public onTextPaste?: () => void; /** * Called when ↑ is pressed in an empty editor. Return `true` to consume @@ -436,13 +429,6 @@ export class CustomEditor extends Editor { return; } - const newlineInput = getNewlineInput(normalized); - if (newlineInput !== undefined) { - this.onInsertNewline?.(); - super.handleInput(newlineInput); - return; - } - if (matchesKey(normalized, Key.up)) { if (this.getText().length === 0 && this.onUpArrowEmpty) { if (this.onUpArrowEmpty()) return; diff --git a/apps/kimi-code/src/tui/controllers/editor-keyboard.ts b/apps/kimi-code/src/tui/controllers/editor-keyboard.ts index cad02c6554..af2d8efd61 100644 --- a/apps/kimi-code/src/tui/controllers/editor-keyboard.ts +++ b/apps/kimi-code/src/tui/controllers/editor-keyboard.ts @@ -281,10 +281,6 @@ export class EditorKeyboardController { host.track('undo'); }; - editor.onInsertNewline = () => { - host.track('shortcut_newline'); - }; - editor.onTextPaste = () => { host.track('shortcut_paste', { kind: 'text' }); }; 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 6ef871208e..1384dfc0bd 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 @@ -586,19 +586,6 @@ describe('CustomEditor paste marker expansion', () => { }); describe('CustomEditor shortcut telemetry hooks', () => { - it('reports newline shortcuts, including Ctrl-J, before delegating to the base editor', () => { - const editor = makeEditor(); - const onInsertNewline = vi.fn(); - editor.onInsertNewline = onInsertNewline; - - editor.handleInput('a'); - editor.handleInput('\n'); - editor.handleInput('\u001B[106;5u'); - - expect(onInsertNewline).toHaveBeenCalledTimes(2); - expect(editor.getText()).toBe('a\n\n'); - }); - it('reports undo shortcuts before delegating to the base editor', () => { const editor = makeEditor(); const onUndo = vi.fn(); diff --git a/apps/kimi-code/test/tui/kimi-tui-message-flow.test.ts b/apps/kimi-code/test/tui/kimi-tui-message-flow.test.ts index 550122428a..bceeea6172 100644 --- a/apps/kimi-code/test/tui/kimi-tui-message-flow.test.ts +++ b/apps/kimi-code/test/tui/kimi-tui-message-flow.test.ts @@ -400,7 +400,6 @@ describe('KimiTUI message flow', () => { const { driver, harness } = await makeDriver(); harness.track.mockClear(); - driver.state.editor.handleInput('\u001B[106;5u'); driver.state.editor.handleInput('\u001F'); delete process.env['VISUAL']; delete process.env['EDITOR']; @@ -408,7 +407,6 @@ describe('KimiTUI message flow', () => { driver.state.editor.onToggleToolExpand?.(); driver.state.editor.onTextPaste?.(); - expect(harness.track).toHaveBeenCalledWith('shortcut_newline', undefined); expect(harness.track).toHaveBeenCalledWith('undo', undefined); expect(harness.track).toHaveBeenCalledWith('shortcut_editor', undefined); expect(harness.track).toHaveBeenCalledWith('shortcut_expand', undefined);