Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/remove-duplicate-newline-handling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---

Remove duplicate newline-shortcut handling from the prompt editor.
14 changes: 0 additions & 14 deletions apps/kimi-code/src/tui/components/editor/custom-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions apps/kimi-code/src/tui/controllers/editor-keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,6 @@ export class EditorKeyboardController {
host.track('undo');
};

editor.onInsertNewline = () => {
host.track('shortcut_newline');
};

editor.onTextPaste = () => {
host.track('shortcut_paste', { kind: 'text' });
};
Expand Down
13 changes: 0 additions & 13 deletions apps/kimi-code/test/tui/components/editor/custom-editor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions apps/kimi-code/test/tui/kimi-tui-message-flow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,13 @@ 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'];
driver.state.editor.onOpenExternalEditor?.();
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);
Expand Down
Loading