Skip to content

refactor: centralize matches_key in keybindings and make char matching case-insensitive - #44

Open
felipecm-br wants to merge 1 commit into
Blankeos:mainfrom
felipecm-br:refactor/keybindings-matches-key
Open

felipecm-br wants to merge 1 commit into
Blankeos:mainfrom
felipecm-br:refactor/keybindings-matches-key

Conversation

@felipecm-br

Copy link
Copy Markdown
Contributor

Description

Centralizes the duplicated matches_key implementations across all controller modules into a single function in src/config/keybindings.rs, while adding case-insensitive matching for character keys and normalizing shifted punctuation.

Details

  • Deduplication: Removed 12 duplicate copies of fn matches_key across controllers (branches, commits, commit_files, diff_mode, files, reflog, remote_branches, remotes, stash, status, tree, and gui/mod.rs), reducing code by 59 lines net.
  • Case-Insensitive Character Matching: Handles terminal emulators that report uppercase character codes with modifiers (e.g. Ctrl+L vs Ctrl+l), preventing ignored shortcuts.
  • Shifted Punctuation Normalization: Handles terminals reporting shifted punctuation (such as < or >) with KeyModifiers::SHIFT.
  • Preserved Semantics: Bare single characters without modifiers distinguish uppercase vs lowercase (e.g. D requires Shift whereas d does not).
  • Unit tests verifying case-insensitivity, modifier enforcement, and shift distinctions.

Validation

  • cargo test --bin lazygitrs (all 372 tests passed)
  • cargo fmt --check

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