Skip to content

Commit 80a1ceb

Browse files
scidominoliamhelmer
authored andcommitted
remove wildcard behavior on keybindings (google-gemini#21315)
1 parent e34ce6d commit 80a1ceb

File tree

10 files changed

+135
-415
lines changed

10 files changed

+135
-415
lines changed

docs/reference/keyboard-shortcuts.md

Lines changed: 57 additions & 57 deletions
Large diffs are not rendered by default.

packages/cli/src/config/keyBindings.test.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -58,46 +58,6 @@ describe('keyBindings config', () => {
5858
const config: KeyBindingConfig = defaultKeyBindings;
5959
expect(config[Command.HOME]).toBeDefined();
6060
});
61-
62-
it('should have correct specific bindings', () => {
63-
// Verify navigation ignores shift
64-
const navUp = defaultKeyBindings[Command.NAVIGATION_UP];
65-
expect(navUp).toContainEqual({ key: 'up', shift: false });
66-
67-
const navDown = defaultKeyBindings[Command.NAVIGATION_DOWN];
68-
expect(navDown).toContainEqual({ key: 'down', shift: false });
69-
70-
// Verify dialog navigation
71-
const dialogNavUp = defaultKeyBindings[Command.DIALOG_NAVIGATION_UP];
72-
expect(dialogNavUp).toContainEqual({ key: 'up', shift: false });
73-
expect(dialogNavUp).toContainEqual({ key: 'k', shift: false });
74-
75-
const dialogNavDown = defaultKeyBindings[Command.DIALOG_NAVIGATION_DOWN];
76-
expect(dialogNavDown).toContainEqual({ key: 'down', shift: false });
77-
expect(dialogNavDown).toContainEqual({ key: 'j', shift: false });
78-
79-
// Verify physical home/end keys for cursor movement
80-
expect(defaultKeyBindings[Command.HOME]).toContainEqual({
81-
key: 'home',
82-
ctrl: false,
83-
shift: false,
84-
});
85-
expect(defaultKeyBindings[Command.END]).toContainEqual({
86-
key: 'end',
87-
ctrl: false,
88-
shift: false,
89-
});
90-
91-
// Verify physical home/end keys for scrolling
92-
expect(defaultKeyBindings[Command.SCROLL_HOME]).toContainEqual({
93-
key: 'home',
94-
ctrl: true,
95-
});
96-
expect(defaultKeyBindings[Command.SCROLL_END]).toContainEqual({
97-
key: 'end',
98-
ctrl: true,
99-
});
100-
});
10161
});
10262

10363
describe('command metadata', () => {

packages/cli/src/config/keyBindings.ts

Lines changed: 27 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -134,27 +134,12 @@ export const defaultKeyBindings: KeyBindingConfig = {
134134
[Command.EXIT]: [{ key: 'd', ctrl: true }],
135135

136136
// Cursor Movement
137-
[Command.HOME]: [
138-
{ key: 'a', ctrl: true },
139-
{ key: 'home', shift: false, ctrl: false },
140-
],
141-
[Command.END]: [
142-
{ key: 'e', ctrl: true },
143-
{ key: 'end', shift: false, ctrl: false },
144-
],
145-
[Command.MOVE_UP]: [
146-
{ key: 'up', shift: false, alt: false, ctrl: false, cmd: false },
147-
],
148-
[Command.MOVE_DOWN]: [
149-
{ key: 'down', shift: false, alt: false, ctrl: false, cmd: false },
150-
],
151-
[Command.MOVE_LEFT]: [
152-
{ key: 'left', shift: false, alt: false, ctrl: false, cmd: false },
153-
],
154-
[Command.MOVE_RIGHT]: [
155-
{ key: 'right', shift: false, alt: false, ctrl: false, cmd: false },
156-
{ key: 'f', ctrl: true },
157-
],
137+
[Command.HOME]: [{ key: 'a', ctrl: true }, { key: 'home' }],
138+
[Command.END]: [{ key: 'e', ctrl: true }, { key: 'end' }],
139+
[Command.MOVE_UP]: [{ key: 'up' }],
140+
[Command.MOVE_DOWN]: [{ key: 'down' }],
141+
[Command.MOVE_LEFT]: [{ key: 'left' }],
142+
[Command.MOVE_RIGHT]: [{ key: 'right' }, { key: 'f', ctrl: true }],
158143
[Command.MOVE_WORD_LEFT]: [
159144
{ key: 'left', ctrl: true },
160145
{ key: 'left', alt: true },
@@ -183,8 +168,8 @@ export const defaultKeyBindings: KeyBindingConfig = {
183168
[Command.DELETE_CHAR_LEFT]: [{ key: 'backspace' }, { key: 'h', ctrl: true }],
184169
[Command.DELETE_CHAR_RIGHT]: [{ key: 'delete' }, { key: 'd', ctrl: true }],
185170
[Command.UNDO]: [
186-
{ key: 'z', cmd: true, shift: false },
187-
{ key: 'z', alt: true, shift: false },
171+
{ key: 'z', cmd: true },
172+
{ key: 'z', alt: true },
188173
],
189174
[Command.REDO]: [
190175
{ key: 'z', ctrl: true, shift: true },
@@ -207,56 +192,33 @@ export const defaultKeyBindings: KeyBindingConfig = {
207192
[Command.PAGE_DOWN]: [{ key: 'pagedown' }],
208193

209194
// History & Search
210-
[Command.HISTORY_UP]: [{ key: 'p', shift: false, ctrl: true }],
211-
[Command.HISTORY_DOWN]: [{ key: 'n', shift: false, ctrl: true }],
195+
[Command.HISTORY_UP]: [{ key: 'p', ctrl: true }],
196+
[Command.HISTORY_DOWN]: [{ key: 'n', ctrl: true }],
212197
[Command.REVERSE_SEARCH]: [{ key: 'r', ctrl: true }],
213-
[Command.REWIND]: [{ key: 'double escape' }],
214-
[Command.SUBMIT_REVERSE_SEARCH]: [{ key: 'return', ctrl: false }],
215-
[Command.ACCEPT_SUGGESTION_REVERSE_SEARCH]: [{ key: 'tab', shift: false }],
198+
[Command.REWIND]: [{ key: 'double escape' }], // for documentation only
199+
[Command.SUBMIT_REVERSE_SEARCH]: [{ key: 'return' }],
200+
[Command.ACCEPT_SUGGESTION_REVERSE_SEARCH]: [{ key: 'tab' }],
216201

217202
// Navigation
218-
[Command.NAVIGATION_UP]: [{ key: 'up', shift: false }],
219-
[Command.NAVIGATION_DOWN]: [{ key: 'down', shift: false }],
203+
[Command.NAVIGATION_UP]: [{ key: 'up' }],
204+
[Command.NAVIGATION_DOWN]: [{ key: 'down' }],
220205
// Navigation shortcuts appropriate for dialogs where we do not need to accept
221206
// text input.
222-
[Command.DIALOG_NAVIGATION_UP]: [
223-
{ key: 'up', shift: false },
224-
{ key: 'k', shift: false },
225-
],
226-
[Command.DIALOG_NAVIGATION_DOWN]: [
227-
{ key: 'down', shift: false },
228-
{ key: 'j', shift: false },
229-
],
230-
[Command.DIALOG_NEXT]: [{ key: 'tab', shift: false }],
207+
[Command.DIALOG_NAVIGATION_UP]: [{ key: 'up' }, { key: 'k' }],
208+
[Command.DIALOG_NAVIGATION_DOWN]: [{ key: 'down' }, { key: 'j' }],
209+
[Command.DIALOG_NEXT]: [{ key: 'tab' }],
231210
[Command.DIALOG_PREV]: [{ key: 'tab', shift: true }],
232211

233212
// Suggestions & Completions
234-
[Command.ACCEPT_SUGGESTION]: [
235-
{ key: 'tab', shift: false },
236-
{ key: 'return', ctrl: false },
237-
],
238-
[Command.COMPLETION_UP]: [
239-
{ key: 'up', shift: false },
240-
{ key: 'p', shift: false, ctrl: true },
241-
],
242-
[Command.COMPLETION_DOWN]: [
243-
{ key: 'down', shift: false },
244-
{ key: 'n', shift: false, ctrl: true },
245-
],
213+
[Command.ACCEPT_SUGGESTION]: [{ key: 'tab' }, { key: 'return' }],
214+
[Command.COMPLETION_UP]: [{ key: 'up' }, { key: 'p', ctrl: true }],
215+
[Command.COMPLETION_DOWN]: [{ key: 'down' }, { key: 'n', ctrl: true }],
246216
[Command.EXPAND_SUGGESTION]: [{ key: 'right' }],
247217
[Command.COLLAPSE_SUGGESTION]: [{ key: 'left' }],
248218

249219
// Text Input
250220
// Must also exclude shift to allow shift+enter for newline
251-
[Command.SUBMIT]: [
252-
{
253-
key: 'return',
254-
shift: false,
255-
alt: false,
256-
ctrl: false,
257-
cmd: false,
258-
},
259-
],
221+
[Command.SUBMIT]: [{ key: 'return' }],
260222
[Command.NEWLINE]: [
261223
{ key: 'return', ctrl: true },
262224
{ key: 'return', cmd: true },
@@ -283,19 +245,17 @@ export const defaultKeyBindings: KeyBindingConfig = {
283245
[Command.TOGGLE_BACKGROUND_SHELL_LIST]: [{ key: 'l', ctrl: true }],
284246
[Command.KILL_BACKGROUND_SHELL]: [{ key: 'k', ctrl: true }],
285247
[Command.UNFOCUS_BACKGROUND_SHELL]: [{ key: 'tab', shift: true }],
286-
[Command.UNFOCUS_BACKGROUND_SHELL_LIST]: [{ key: 'tab', shift: false }],
287-
[Command.SHOW_BACKGROUND_SHELL_UNFOCUS_WARNING]: [
288-
{ key: 'tab', shift: false },
289-
],
290-
[Command.SHOW_SHELL_INPUT_UNFOCUS_WARNING]: [{ key: 'tab', shift: false }],
248+
[Command.UNFOCUS_BACKGROUND_SHELL_LIST]: [{ key: 'tab' }],
249+
[Command.SHOW_BACKGROUND_SHELL_UNFOCUS_WARNING]: [{ key: 'tab' }],
250+
[Command.SHOW_SHELL_INPUT_UNFOCUS_WARNING]: [{ key: 'tab' }],
291251
[Command.BACKGROUND_SHELL_SELECT]: [{ key: 'return' }],
292252
[Command.BACKGROUND_SHELL_ESCAPE]: [{ key: 'escape' }],
293253
[Command.SHOW_MORE_LINES]: [{ key: 'o', ctrl: true }],
294254
[Command.EXPAND_PASTE]: [{ key: 'o', ctrl: true }],
295-
[Command.FOCUS_SHELL_INPUT]: [{ key: 'tab', shift: false }],
255+
[Command.FOCUS_SHELL_INPUT]: [{ key: 'tab' }],
296256
[Command.UNFOCUS_SHELL_INPUT]: [{ key: 'tab', shift: true }],
297257
[Command.CLEAR_SCREEN]: [{ key: 'l', ctrl: true }],
298-
[Command.RESTART_APP]: [{ key: 'r' }],
258+
[Command.RESTART_APP]: [{ key: 'r' }, { key: 'r', shift: true }],
299259
[Command.SUSPEND_APP]: [{ key: 'z', ctrl: true }],
300260
};
301261

packages/cli/src/ui/components/__snapshots__/AskUserDialog.test.tsx.snap

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@ Enter to submit · Esc to cancel
1111
"
1212
`;
1313

14-
exports[`AskUserDialog > Choice question placeholder > uses default placeholder when not provided 2`] = `
15-
"Select your preferred language:
16-
17-
1. TypeScript
18-
2. JavaScript
19-
● 3. Enter a custom value
20-
21-
Enter to submit · Esc to cancel
22-
"
23-
`;
24-
2514
exports[`AskUserDialog > Choice question placeholder > uses placeholder for "Other" option when provided 1`] = `
2615
"Select your preferred language:
2716
@@ -33,17 +22,6 @@ Enter to submit · Esc to cancel
3322
"
3423
`;
3524

36-
exports[`AskUserDialog > Choice question placeholder > uses placeholder for "Other" option when provided 2`] = `
37-
"Select your preferred language:
38-
39-
1. TypeScript
40-
2. JavaScript
41-
● 3. Type another language...
42-
43-
Enter to submit · Esc to cancel
44-
"
45-
`;
46-
4725
exports[`AskUserDialog > Scroll Arrows (useAlternateBuffer: false) > shows scroll arrows correctly when useAlternateBuffer is false 1`] = `
4826
"Choose an option
4927
@@ -58,20 +36,6 @@ Enter to select · ↑/↓ to navigate · Esc to cancel
5836
"
5937
`;
6038

61-
exports[`AskUserDialog > Scroll Arrows (useAlternateBuffer: false) > shows scroll arrows correctly when useAlternateBuffer is false 2`] = `
62-
"Choose an option
63-
64-
65-
● 1. Option 1
66-
Description 1
67-
2. Option 2
68-
Description 2
69-
70-
71-
Enter to select · ↑/↓ to navigate · Esc to cancel
72-
"
73-
`;
74-
7539
exports[`AskUserDialog > Scroll Arrows (useAlternateBuffer: true) > shows scroll arrows correctly when useAlternateBuffer is true 1`] = `
7640
"Choose an option
7741
@@ -111,45 +75,6 @@ Enter to select · ↑/↓ to navigate · Esc to cancel
11175
"
11276
`;
11377

114-
exports[`AskUserDialog > Scroll Arrows (useAlternateBuffer: true) > shows scroll arrows correctly when useAlternateBuffer is true 2`] = `
115-
"Choose an option
116-
117-
● 1. Option 1
118-
Description 1
119-
2. Option 2
120-
Description 2
121-
3. Option 3
122-
Description 3
123-
4. Option 4
124-
Description 4
125-
5. Option 5
126-
Description 5
127-
6. Option 6
128-
Description 6
129-
7. Option 7
130-
Description 7
131-
8. Option 8
132-
Description 8
133-
9. Option 9
134-
Description 9
135-
10. Option 10
136-
Description 10
137-
11. Option 11
138-
Description 11
139-
12. Option 12
140-
Description 12
141-
13. Option 13
142-
Description 13
143-
14. Option 14
144-
Description 14
145-
15. Option 15
146-
Description 15
147-
16. Enter a custom value
148-
149-
Enter to select · ↑/↓ to navigate · Esc to cancel
150-
"
151-
`;
152-
15378
exports[`AskUserDialog > Text type questions > renders text input for type: "text" 1`] = `
15479
"What should we name this component?
15580

0 commit comments

Comments
 (0)