Skip to content

Skip unregistered commands in FindCommandByChord, matching ExecuteChord [patch] - #159

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/find-command-registered-136
Sep 30, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/find-command-registered-136

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #136

Problem

The #116 fix made ExecuteChord skip bindings whose command is no longer registered. FindCommandByChord (both overloads) still returned the first binding. So after a command was unregistered, the lookup that UIs, the README and the demo use to label a key named a command that no longer exists, while pressing the key ran a different one.

Change

  • ExecuteChord and FindCommandByChord now share one private helper, FindRegisteredCommand. It returns the first binding whose command is still registered, so the two methods cannot drift apart again.
  • The IKeybindingService doc comments now say that FindCommandByChord skips unregistered commands.
  • I did not add a raw "any binding" lookup, since nothing in the repo needs one yet.

Behaviour change to note

ProfileChordAccessTests.FindAndExecuteChord_UseTheLockedSnapshot asserted the old behaviour ("FindCommandByChord does not filter by registration"), which is exactly what the issue asks to change. I updated that assertion to expect null, the same result ExecuteChord gives.

Tests

Two new tests in ExecuteChordTests, each covering both the active-profile and explicit-profile overloads:

  • FindCommandByChord_FirstBindingUnregistered_AgreesWithExecuteChord: a then b are bound, a is unregistered, and the result is b.
  • FindCommandByChord_OnlyBindingUnregistered_ReturnsNull

Both fail on main and pass with the fix. The full suite passes locally: 136/136.

🤖 Generated with Claude Code

https://claude.ai/code/session_019UNSUUrn4o84JfkEVaD3xg


Generated by Claude Code

…rd [patch]

The #116 fix taught ExecuteChord to skip bindings whose command is no longer
registered, but FindCommandByChord still returned the first binding. Once a
command was unregistered, "what does this chord do?" named a command that no
longer existed while ExecuteChord ran a different one. Both methods now share
one helper, so they cannot drift apart again.

Fixes #136

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019UNSUUrn4o84JfkEVaD3xg
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 879d179 into main Sep 30, 2026
14 checks passed
@matt-edmondson
matt-edmondson deleted the fix/find-command-registered-136 branch September 30, 2026 04:01
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.

FindCommandByChord reports an unregistered command for a chord, while ExecuteChord for the same chord runs a different, registered command

2 participants