mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-20 10:10:56 -07:00
Remove sequence binding (#16664)
This commit is contained in:
committed by
GitHub
parent
5ed275ce39
commit
fb7640886b
@@ -28,12 +28,9 @@ describe('keyBindings config', () => {
|
||||
it('should have valid key binding structures', () => {
|
||||
for (const [_, bindings] of Object.entries(defaultKeyBindings)) {
|
||||
for (const binding of bindings) {
|
||||
// Each binding should have either key or sequence, but not both
|
||||
const hasKey = binding.key !== undefined;
|
||||
const hasSequence = binding.sequence !== undefined;
|
||||
|
||||
expect(hasKey || hasSequence).toBe(true);
|
||||
expect(hasKey && hasSequence).toBe(false);
|
||||
// Each binding must have a key name
|
||||
expect(typeof binding.key).toBe('string');
|
||||
expect(binding.key.length).toBeGreaterThan(0);
|
||||
|
||||
// Modifier properties should be boolean or undefined
|
||||
if (binding.ctrl !== undefined) {
|
||||
|
||||
@@ -94,9 +94,7 @@ export enum Command {
|
||||
*/
|
||||
export interface KeyBinding {
|
||||
/** The key name (e.g., 'a', 'return', 'tab', 'escape') */
|
||||
key?: string;
|
||||
/** The key sequence (e.g., '\x18' for Ctrl+X) - alternative to key name */
|
||||
sequence?: string;
|
||||
key: string;
|
||||
/** Control key requirement: true=must be pressed, false=must not be pressed, undefined=ignore */
|
||||
ctrl?: boolean;
|
||||
/** Shift key requirement: true=must be pressed, false=must not be pressed, undefined=ignore */
|
||||
@@ -221,10 +219,7 @@ export const defaultKeyBindings: KeyBindingConfig = {
|
||||
],
|
||||
|
||||
// External tools
|
||||
[Command.OPEN_EXTERNAL_EDITOR]: [
|
||||
{ key: 'x', ctrl: true },
|
||||
{ sequence: '\x18', ctrl: true },
|
||||
],
|
||||
[Command.OPEN_EXTERNAL_EDITOR]: [{ key: 'x', ctrl: true }],
|
||||
[Command.PASTE_CLIPBOARD]: [
|
||||
{ key: 'v', ctrl: true },
|
||||
{ key: 'v', command: true },
|
||||
|
||||
@@ -256,10 +256,7 @@ describe('keyMatchers', () => {
|
||||
// External tools
|
||||
{
|
||||
command: Command.OPEN_EXTERNAL_EDITOR,
|
||||
positive: [
|
||||
createKey('x', { ctrl: true }),
|
||||
{ ...createKey('\x18'), sequence: '\x18', ctrl: true },
|
||||
],
|
||||
positive: [createKey('x', { ctrl: true })],
|
||||
negative: [createKey('x'), createKey('c', { ctrl: true })],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -13,19 +13,7 @@ import { Command, defaultKeyBindings } from '../config/keyBindings.js';
|
||||
* Pure data-driven matching logic
|
||||
*/
|
||||
function matchKeyBinding(keyBinding: KeyBinding, key: Key): boolean {
|
||||
// Either key name or sequence must match (but not both should be defined)
|
||||
let keyMatches = false;
|
||||
|
||||
if (keyBinding.key !== undefined) {
|
||||
keyMatches = keyBinding.key === key.name;
|
||||
} else if (keyBinding.sequence !== undefined) {
|
||||
keyMatches = keyBinding.sequence === key.sequence;
|
||||
} else {
|
||||
// Neither key nor sequence defined - invalid binding
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!keyMatches) {
|
||||
if (keyBinding.key !== key.name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user