Skip to content

Chord.Parse / ParseChord accept a phrase string like "Ctrl+K, Ctrl+C" and return one chord with a made-up key "K, CTRL" instead of throwing #134

Description

@matt-edmondson

What's wrong

KeyStringTokenizer.SplitChord (Keybinding/Models/KeyStringTokenizer.cs:24) splits only on +. A , that follows a key is appended to the current token as an ordinary character.

The resulting token is passed to Note, which accepts any non-blank string (Keybinding/Models/MusicalTypes.cs:31-46). The documented NoteName pattern ^[A-Z0-9_]+$ is never checked.

Two public entry points take this path:

  • Chord.Parse (MusicalTypes.cs:268-292)
  • KeybindingService.ParseChord (Services/KeybindingService.cs:208-226)

Failure scenario

Chord.Parse("Ctrl+K, Ctrl+C") and service.ParseChord("Ctrl+K, Ctrl+C") both return a 3-note chord without throwing. The notes are C, CTRL and "K, CTRL".

  • ToString() on that chord gives "Ctrl+C+K, CTRL".
  • Phrase.Parse reads that same string back as two chords, so a bound chord's display string means something different when parsed again.

I reproduced this with a scratch MSTest against the current main.

The README says "Invalid key combinations are rejected during parsing." In practice, a user who types a VS-style sequence into a chord field gets a binding that can never fire, and sees no error. Keys with inner whitespace, such as "Page Up", get through the same way.

Suggested fix / acceptance criteria

Activity

  1. matt-edmondson commented on Sep 27, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingreadyFully specified; implement as written

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions