mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
fix: Ctrl+E should move to current line end, not buffer end (#6729)
Co-authored-by: Jacob Richman <jacob314@gmail.com> Co-authored-by: Arya Gummadi <aryagummadi@google.com>
This commit is contained in:
@@ -119,9 +119,9 @@ describe('InputPrompt', () => {
|
|||||||
visualScrollRow: 0,
|
visualScrollRow: 0,
|
||||||
handleInput: vi.fn(),
|
handleInput: vi.fn(),
|
||||||
move: vi.fn(),
|
move: vi.fn(),
|
||||||
moveToOffset: (offset: number) => {
|
moveToOffset: vi.fn((offset: number) => {
|
||||||
mockBuffer.cursor = [0, offset];
|
mockBuffer.cursor = [0, offset];
|
||||||
},
|
}),
|
||||||
killLineRight: vi.fn(),
|
killLineRight: vi.fn(),
|
||||||
killLineLeft: vi.fn(),
|
killLineLeft: vi.fn(),
|
||||||
openInExternalEditor: vi.fn(),
|
openInExternalEditor: vi.fn(),
|
||||||
@@ -1469,4 +1469,42 @@ describe('InputPrompt', () => {
|
|||||||
unmount();
|
unmount();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Ctrl+E keyboard shortcut', () => {
|
||||||
|
it('should move cursor to end of current line in multiline input', async () => {
|
||||||
|
props.buffer.text = 'line 1\nline 2\nline 3';
|
||||||
|
props.buffer.cursor = [1, 2];
|
||||||
|
props.buffer.lines = ['line 1', 'line 2', 'line 3'];
|
||||||
|
|
||||||
|
const { stdin, unmount } = renderWithProviders(
|
||||||
|
<InputPrompt {...props} />,
|
||||||
|
);
|
||||||
|
await wait();
|
||||||
|
|
||||||
|
stdin.write('\x05'); // Ctrl+E
|
||||||
|
await wait();
|
||||||
|
|
||||||
|
expect(props.buffer.move).toHaveBeenCalledWith('end');
|
||||||
|
expect(props.buffer.moveToOffset).not.toHaveBeenCalled();
|
||||||
|
unmount();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should move cursor to end of current line for single line input', async () => {
|
||||||
|
props.buffer.text = 'single line text';
|
||||||
|
props.buffer.cursor = [0, 5];
|
||||||
|
props.buffer.lines = ['single line text'];
|
||||||
|
|
||||||
|
const { stdin, unmount } = renderWithProviders(
|
||||||
|
<InputPrompt {...props} />,
|
||||||
|
);
|
||||||
|
await wait();
|
||||||
|
|
||||||
|
stdin.write('\x05'); // Ctrl+E
|
||||||
|
await wait();
|
||||||
|
|
||||||
|
expect(props.buffer.move).toHaveBeenCalledWith('end');
|
||||||
|
expect(props.buffer.moveToOffset).not.toHaveBeenCalled();
|
||||||
|
unmount();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -482,7 +482,6 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
|||||||
}
|
}
|
||||||
if (keyMatchers[Command.END](key)) {
|
if (keyMatchers[Command.END](key)) {
|
||||||
buffer.move('end');
|
buffer.move('end');
|
||||||
buffer.moveToOffset(cpLen(buffer.text));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Ctrl+C (Clear input)
|
// Ctrl+C (Clear input)
|
||||||
|
|||||||
Reference in New Issue
Block a user