Skip to content

fix(key): match the plus key in MatchString - #230

Open
RaphaelFakhri wants to merge 1 commit into
charmbracelet:mainfrom
RaphaelFakhri:fix/match-plus-key
Open

RaphaelFakhri wants to merge 1 commit into
charmbracelet:mainfrom
RaphaelFakhri:fix/match-plus-key

Conversation

@RaphaelFakhri

Copy link
Copy Markdown
  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features).

This is a bug fix, not a new feature.

Problem

Key.MatchString splits its input on +, so "+" and "ctrl++" leave two empty parts where the plus key should be. Neither string matches the plus key, even though Keystroke() returns "ctrl++" for Ctrl+Plus.

Fix

When the input is "+" or ends with "++", replace the two trailing empty parts with "+" before parsing the modifiers and key. Other inputs parse as before.

Tests

TestKeyMatchString gains cases for "+", "ctrl++", "ctrl+alt++", and a negative case where "ctrl++" must not match Ctrl+A.

  • Before the fix: go test -run TestKeyMatchString -v . fails the plus, ctrl+plus and ctrl+alt+plus cases (3 failed, 45 passed).
  • After the fix: all 48 cases pass, go test ./... passes, and golangci-lint run ./... reports 0 issues.

Fixes #229

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.

Key.MatchString can't match the plus key

1 participant