fix(cli): fix newline support broken in previous PR (#17159)

This commit is contained in:
Tommaso Sciortino
2026-01-20 16:20:51 -08:00
committed by GitHub
parent 211d2c5fdd
commit aceb06a587
2 changed files with 18 additions and 0 deletions

View File

@@ -1096,6 +1096,23 @@ describe('useTextBuffer', () => {
expect(getBufferState(result).lines).toEqual(['', '']);
});
it('should handle Ctrl+J as newline', () => {
const { result } = renderHook(() =>
useTextBuffer({ viewport, isValidPath: () => false }),
);
act(() =>
result.current.handleInput({
name: 'j',
ctrl: true,
meta: false,
shift: false,
insertable: false,
sequence: '\n',
}),
);
expect(getBufferState(result).lines).toEqual(['', '']);
});
it('should do nothing for a tab key press', () => {
const { result } = renderHook(() =>
useTextBuffer({ viewport, isValidPath: () => false }),

View File

@@ -2292,6 +2292,7 @@ export function useTextBuffer({
if (key.name === 'paste') insert(input, { paste: true });
else if (keyMatchers[Command.RETURN](key)) newline();
else if (keyMatchers[Command.NEWLINE](key)) newline();
else if (keyMatchers[Command.MOVE_LEFT](key)) move('left');
else if (keyMatchers[Command.MOVE_RIGHT](key)) move('right');
else if (keyMatchers[Command.MOVE_UP](key)) move('up');