Skip to content

fix: leader key detection for ctrl+x and other modifier keys#37

Merged
oribarilan merged 2 commits into
mainfrom
fix/leader-key-detection
Jun 13, 2026
Merged

fix: leader key detection for ctrl+x and other modifier keys#37
oribarilan merged 2 commits into
mainfrom
fix/leader-key-detection

Conversation

@oribarilan

@oribarilan oribarilan commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Fixes leader key being broken for any config with modifiers, including the default ctrl+x.

parseLeaderKey("ctrl+x") expected vim-style C-x notation but OpenCode returns ctrl+x format. The parser never recognized the modifiers, so every match failed silently.

Fix: drop the format translation. New src/leader.ts matches against OpenCode's native KeyLike type directly, with modifier alias support (control, alt, option) and case normalization. Removes ParsedLeader/parseLeaderKey/matchesLeader from vim.ts.

Ref: #22

Drop the ParsedLeader/parseLeaderKey format translation layer that
expected vim-style C-x notation. OpenCode's keybinds API returns
ctrl+x format, so the default leader key was silently broken.

New approach: work with OpenCode's native KeyLike type directly.
A new src/leader.ts module handles matching with modifier alias
support (control, alt, option, super) and case normalization.

- Extract matchesKeyLike, findMatchingLeader, leaderChar to leader.ts
- Remove ParsedLeader, parseLeaderKey, matchesLeader from vim.ts
- Remove leader parameter from handleInsertKey
- Move insert-mode leader swallowing to the intercept (runs after
  handleInsertKey so escape/return/tab/ctrl+o keep priority)
- Update question/permission prompt block to use new functions
- Support multiple leader bindings, filter 'none'/'false' sentinels
- 26 unit tests for the new leader module
@oribarilan oribarilan changed the title fix: leader key detection for modifier-based configs like ctrl+x fix: leader key detection for ctrl+x and other modifier keys Jun 13, 2026
@oribarilan oribarilan merged commit 4180219 into main Jun 13, 2026
1 check passed
@oribarilan oribarilan deleted the fix/leader-key-detection branch June 13, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant