Parse "Ctrl++" and "Ctrl+," as the plus and comma keys - #110
Merged
Merged
Conversation
Chord.Parse, Phrase.Parse, and KeybindingService.ParseChord/ParsePhrase
split on '+' and ',' with RemoveEmptyEntries, so "Ctrl++" and "Ctrl+,"
silently became a lone Ctrl. Route all four through one tokenizer that
treats a separator where a key is expected as the literal key, and throws
ArgumentException when a key is missing ("Ctrl+", "A,,B") instead of
dropping it.
Fixes #108
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q8KgDr8CfZLWPQ5o6nZdcV
Move the lookahead that decides whether a separator is a literal key into its own method, and use Assert.Contains in the separator key tests, per SonarCloud S3776 and MSTEST0037. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q8KgDr8CfZLWPQ5o6nZdcV
|
This was referenced Sep 26, 2026
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 #108
What was wrong
Four parsers split on
'+'and','withRemoveEmptyEntries:Chord.Parse,Phrase.Parse,KeybindingService.ParseChordandKeybindingService.ParsePhrase. As a result,"Ctrl++"and"Ctrl+,"both silently parsed as a loneCtrl.Change
A new internal
KeyStringTokenizer(Models/KeyStringTokenizer.cs) now does the splitting for all four parsers. It works like this:"Ctrl++"becomes[Ctrl, +]."Ctrl+,"becomes[Ctrl, ,]."Ctrl+,, R"becomes the phraseCtrl+Comma, R.ArgumentException, which is the exception these methods already document. Examples:"Ctrl+","A++B","Ctrl+R,","Ctrl+R,,R". None of them are dropped silently any more.ToString()output parses back to an equal phrase.ParsePhraseon whitespace still returns an empty phrase. I have not changed the separate modifier-alias problem, which is #107.Behaviour change: inputs with a dangling separator, such as
"Ctrl+", used to parse as the keys that were present. They now throw. The issue explicitly asks for this ("input that parses to fewer keys than the user typed should never succeed silently").Tests
The new
Keybinding.Test/SeparatorKeyParsingTests.csadds 17 test cases. They coverChord.Parse,Phrase.Parse, the service parsers, round-tripping, and the missing-key cases that should throw.With the parser changes reverted, 12 of them fail. With the fix in place, the full suite passes, 68 of 68.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Q8KgDr8CfZLWPQ5o6nZdcV
Generated by Claude Code