fix: leader key detection for ctrl+x and other modifier keys#37
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes leader key being broken for any config with modifiers, including the default
ctrl+x.parseLeaderKey("ctrl+x")expected vim-styleC-xnotation but OpenCode returnsctrl+xformat. The parser never recognized the modifiers, so every match failed silently.Fix: drop the format translation. New
src/leader.tsmatches against OpenCode's nativeKeyLiketype directly, with modifier alias support (control,alt,option) and case normalization. RemovesParsedLeader/parseLeaderKey/matchesLeaderfromvim.ts.Ref: #22