mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-14 23:31:13 -07:00
Fix: add back fastreturn support (#16440)
This commit is contained in:
committed by
GitHub
parent
8437ce940a
commit
e049d5e4e8
@@ -16,7 +16,9 @@ import {
|
||||
KeypressProvider,
|
||||
useKeypressContext,
|
||||
ESC_TIMEOUT,
|
||||
FAST_RETURN_TIMEOUT,
|
||||
} from './KeypressContext.js';
|
||||
import { terminalCapabilityManager } from '../utils/terminalCapabilityManager.js';
|
||||
import { useStdin } from 'ink';
|
||||
import { EventEmitter } from 'node:events';
|
||||
|
||||
@@ -154,6 +156,53 @@ describe('KeypressContext', () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe('Fast return buffering', () => {
|
||||
let kittySpy: ReturnType<typeof vi.spyOn>;
|
||||
|
||||
beforeEach(() => {
|
||||
kittySpy = vi
|
||||
.spyOn(terminalCapabilityManager, 'isKittyProtocolEnabled')
|
||||
.mockReturnValue(false);
|
||||
});
|
||||
|
||||
afterEach(() => kittySpy.mockRestore());
|
||||
|
||||
it('should buffer return key pressed quickly after another key', async () => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
|
||||
act(() => stdin.write('a'));
|
||||
expect(keyHandler).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ name: 'a' }),
|
||||
);
|
||||
|
||||
act(() => stdin.write('\r'));
|
||||
|
||||
expect(keyHandler).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({
|
||||
name: '',
|
||||
sequence: '\r',
|
||||
insertable: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should NOT buffer return key if delay is long enough', async () => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
|
||||
act(() => stdin.write('a'));
|
||||
|
||||
vi.advanceTimersByTime(FAST_RETURN_TIMEOUT + 1);
|
||||
|
||||
act(() => stdin.write('\r'));
|
||||
|
||||
expect(keyHandler).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({
|
||||
name: 'return',
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Escape key handling', () => {
|
||||
it('should recognize escape key (keycode 27) in kitty protocol', async () => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
|
||||
Reference in New Issue
Block a user