mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-28 22:14:52 -07:00
feat(cli): support literal character keybindings and extended Kitty protocol keys (#21972)
This commit is contained in:
committed by
GitHub
parent
f8ad3a200a
commit
075e0b1a81
@@ -97,13 +97,6 @@ describe('KeyBinding', () => {
|
||||
'Invalid keybinding key: "ctlr+a" in "ctlr+a"',
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw an error for literal "+" as key (must use "=")', () => {
|
||||
// VS Code style peeling logic results in "+" as the remains
|
||||
expect(() => new KeyBinding('alt++')).toThrow(
|
||||
'Invalid keybinding key: "+" in "alt++"',
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -110,10 +110,8 @@ export enum Command {
|
||||
* Data-driven key binding structure for user configuration
|
||||
*/
|
||||
export class KeyBinding {
|
||||
private static readonly VALID_KEYS = new Set([
|
||||
...'abcdefghijklmnopqrstuvwxyz0123456789', // Letters & Numbers
|
||||
..."`-=[]\\;',./", // Punctuation
|
||||
...Array.from({ length: 19 }, (_, i) => `f${i + 1}`), // Function Keys
|
||||
private static readonly VALID_LONG_KEYS = new Set([
|
||||
...Array.from({ length: 35 }, (_, i) => `f${i + 1}`), // Function Keys
|
||||
...Array.from({ length: 10 }, (_, i) => `numpad${i}`), // Numpad Numbers
|
||||
// Navigation & Actions
|
||||
'left',
|
||||
@@ -130,6 +128,7 @@ export class KeyBinding {
|
||||
'space',
|
||||
'backspace',
|
||||
'delete',
|
||||
'clear',
|
||||
'pausebreak',
|
||||
'capslock',
|
||||
'insert',
|
||||
@@ -193,8 +192,11 @@ export class KeyBinding {
|
||||
|
||||
const key = remains;
|
||||
|
||||
if (!KeyBinding.VALID_KEYS.has(key)) {
|
||||
throw new Error(`Invalid keybinding key: "${key}" in "${pattern}"`);
|
||||
if ([...key].length !== 1 && !KeyBinding.VALID_LONG_KEYS.has(key)) {
|
||||
throw new Error(
|
||||
`Invalid keybinding key: "${key}" in "${pattern}".` +
|
||||
` Must be a single character or one of: ${[...KeyBinding.VALID_LONG_KEYS].join(', ')}`,
|
||||
);
|
||||
}
|
||||
|
||||
this.key = key;
|
||||
|
||||
Reference in New Issue
Block a user