mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 13:22:35 -07:00
Support command/ctrl/alt backspace correctly (#17175)
This commit is contained in:
committed by
GitHub
parent
e894871afc
commit
f190b87223
@@ -69,7 +69,7 @@ export function keyToAnsi(key: Key): string | null {
|
||||
}
|
||||
|
||||
// If it's a simple character, return it.
|
||||
if (!key.ctrl && !key.meta && key.sequence) {
|
||||
if (!key.ctrl && !key.cmd && key.sequence) {
|
||||
return key.sequence;
|
||||
}
|
||||
|
||||
|
||||
@@ -314,8 +314,8 @@ describe('useApprovalModeIndicator', () => {
|
||||
act(() => {
|
||||
capturedUseKeypressHandler({
|
||||
name: 'a',
|
||||
ctrl: true,
|
||||
shift: true,
|
||||
ctrl: true,
|
||||
} as Key);
|
||||
});
|
||||
expect(mockConfigInstance.setApprovalMode).not.toHaveBeenCalled();
|
||||
|
||||
@@ -114,7 +114,13 @@ describe(`useKeypress`, () => {
|
||||
const key = { name: 'return', sequence: '\x1B\r' };
|
||||
act(() => stdin.write(key.sequence));
|
||||
expect(onKeypress).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ ...key, meta: true }),
|
||||
expect.objectContaining({
|
||||
...key,
|
||||
shift: false,
|
||||
alt: true,
|
||||
ctrl: false,
|
||||
cmd: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -140,9 +146,10 @@ describe(`useKeypress`, () => {
|
||||
expect(onKeypress).toHaveBeenCalledTimes(1);
|
||||
expect(onKeypress).toHaveBeenCalledWith({
|
||||
name: 'paste',
|
||||
ctrl: false,
|
||||
meta: false,
|
||||
shift: false,
|
||||
alt: false,
|
||||
ctrl: false,
|
||||
cmd: false,
|
||||
insertable: true,
|
||||
sequence: pasteText,
|
||||
});
|
||||
|
||||
@@ -59,7 +59,8 @@ describe('useSelectionList', () => {
|
||||
name,
|
||||
sequence,
|
||||
ctrl: options.ctrl ?? false,
|
||||
meta: false,
|
||||
cmd: false,
|
||||
alt: false,
|
||||
shift: options.shift ?? false,
|
||||
insertable: false,
|
||||
};
|
||||
@@ -328,7 +329,8 @@ describe('useSelectionList', () => {
|
||||
name,
|
||||
sequence: name,
|
||||
ctrl: false,
|
||||
meta: false,
|
||||
cmd: false,
|
||||
alt: false,
|
||||
shift: false,
|
||||
insertable: true,
|
||||
};
|
||||
@@ -377,7 +379,8 @@ describe('useSelectionList', () => {
|
||||
name,
|
||||
sequence: name,
|
||||
ctrl: false,
|
||||
meta: false,
|
||||
cmd: false,
|
||||
alt: false,
|
||||
shift: false,
|
||||
insertable: false,
|
||||
};
|
||||
|
||||
@@ -36,9 +36,10 @@ vi.mock('../contexts/VimModeContext.js', () => ({
|
||||
const createKey = (partial: Partial<Key>): Key => ({
|
||||
name: partial.name || '',
|
||||
sequence: partial.sequence || '',
|
||||
ctrl: partial.ctrl || false,
|
||||
meta: partial.meta || false,
|
||||
shift: partial.shift || false,
|
||||
alt: partial.alt || false,
|
||||
ctrl: partial.ctrl || false,
|
||||
cmd: partial.cmd || false,
|
||||
insertable: partial.insertable || false,
|
||||
...partial,
|
||||
});
|
||||
|
||||
@@ -280,8 +280,9 @@ export function useVim(buffer: TextBuffer, onSubmit?: (value: string) => void) {
|
||||
// Special handling for Enter key to allow command submission (lower priority than completion)
|
||||
if (
|
||||
normalizedKey.name === 'return' &&
|
||||
!normalizedKey.alt &&
|
||||
!normalizedKey.ctrl &&
|
||||
!normalizedKey.meta
|
||||
!normalizedKey.cmd
|
||||
) {
|
||||
if (buffer.text.trim() && onSubmit) {
|
||||
// Handle command submission directly
|
||||
@@ -309,9 +310,10 @@ export function useVim(buffer: TextBuffer, onSubmit?: (value: string) => void) {
|
||||
(key: Key): Key => ({
|
||||
name: key.name || '',
|
||||
sequence: key.sequence || '',
|
||||
ctrl: key.ctrl || false,
|
||||
meta: key.meta || false,
|
||||
shift: key.shift || false,
|
||||
alt: key.alt || false,
|
||||
ctrl: key.ctrl || false,
|
||||
cmd: key.cmd || false,
|
||||
insertable: key.insertable || false,
|
||||
}),
|
||||
[],
|
||||
|
||||
Reference in New Issue
Block a user