diff --git a/packages/cli/src/ui/components/InputPrompt.test.tsx b/packages/cli/src/ui/components/InputPrompt.test.tsx
index a3346490..c6fba806 100644
--- a/packages/cli/src/ui/components/InputPrompt.test.tsx
+++ b/packages/cli/src/ui/components/InputPrompt.test.tsx
@@ -119,9 +119,9 @@ describe('InputPrompt', () => {
visualScrollRow: 0,
handleInput: vi.fn(),
move: vi.fn(),
- moveToOffset: (offset: number) => {
+ moveToOffset: vi.fn((offset: number) => {
mockBuffer.cursor = [0, offset];
- },
+ }),
killLineRight: vi.fn(),
killLineLeft: vi.fn(),
openInExternalEditor: vi.fn(),
@@ -1469,4 +1469,42 @@ describe('InputPrompt', () => {
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(
+ ,
+ );
+ 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(
+ ,
+ );
+ await wait();
+
+ stdin.write('\x05'); // Ctrl+E
+ await wait();
+
+ expect(props.buffer.move).toHaveBeenCalledWith('end');
+ expect(props.buffer.moveToOffset).not.toHaveBeenCalled();
+ unmount();
+ });
+ });
});
diff --git a/packages/cli/src/ui/components/InputPrompt.tsx b/packages/cli/src/ui/components/InputPrompt.tsx
index 215962ce..1547e2c8 100644
--- a/packages/cli/src/ui/components/InputPrompt.tsx
+++ b/packages/cli/src/ui/components/InputPrompt.tsx
@@ -482,7 +482,6 @@ export const InputPrompt: React.FC = ({
}
if (keyMatchers[Command.END](key)) {
buffer.move('end');
- buffer.moveToOffset(cpLen(buffer.text));
return;
}
// Ctrl+C (Clear input)