Support ctrl-C and Ctrl-D correctly Refactor so InputPrompt has priority over AppContainer for input handling. (#17993)

This commit is contained in:
Jacob Richman
2026-01-30 16:11:14 -08:00
committed by GitHub
parent 0fe8492569
commit 00fdb30211
6 changed files with 193 additions and 62 deletions

View File

@@ -1515,6 +1515,50 @@ describe('useTextBuffer', () => {
expect(getBufferState(result).text).toBe('');
});
it('should handle CLEAR_INPUT (Ctrl+C)', () => {
const { result } = renderHook(() =>
useTextBuffer({
initialText: 'hello',
viewport,
isValidPath: () => false,
}),
);
expect(getBufferState(result).text).toBe('hello');
let handled = false;
act(() => {
handled = result.current.handleInput({
name: 'c',
shift: false,
alt: false,
ctrl: true,
cmd: false,
insertable: false,
sequence: '\u0003',
});
});
expect(handled).toBe(true);
expect(getBufferState(result).text).toBe('');
});
it('should NOT handle CLEAR_INPUT if buffer is empty', () => {
const { result } = renderHook(() =>
useTextBuffer({ viewport, isValidPath: () => false }),
);
let handled = true;
act(() => {
handled = result.current.handleInput({
name: 'c',
shift: false,
alt: false,
ctrl: true,
cmd: false,
insertable: false,
sequence: '\u0003',
});
});
expect(handled).toBe(false);
});
it('should handle "Backspace" key', () => {
const { result } = renderHook(() =>
useTextBuffer({