Skip to content

Track only this manager's commands as persisted after a save [patch] - #216

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/214-persisted-command-ids
Nov 4, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/214-persisted-command-ids

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #214

What changed

After writing commands.json, KeybindingManager.SaveAsync recorded every id it wrote in _persistedCommandIds. That included stored commands it had only carried through for another manager. On the next save, the merge read each of those as "persisted by me and no longer registered", so it dropped them from the file.

The post-save bookkeeping now records only the ids registered in this manager (commandIds), which mirrors the profile path. A command this manager unregisters is still removed, because it is absent from commandIds and the persisted set no longer holds it after the save that drops it.

This is a one-line change inside the post-save lock block. Open PR #204 (#195) reworks the read and merge just above it, but leaves that block alone. I checked with git merge-tree that this branch and #204 merge cleanly in either order.

Tests (SaveWithoutInitializeTests)

  • SaveAsync_TwiceWithoutInitialize_KeepsStoredCommands: repro A. file.save and its Ctrl+S binding survive a reload after a second uninitialised save.
  • SaveAsync_TwiceAfterAnotherManagerSaved_KeepsItsCommand: repro B. b.cmd survives a saving twice after b saved.
  • SaveAsync_CommandUnregisteredAfterItsFirstSave_IsRemovedOnTheNext: guard. A command registered, saved, then unregistered in the same manager is still deleted on the next save.

With the KeybindingManager.cs change reverted, the first two fail. The guard passes either way by design. With the change, the full suite passes: 331/331.


Generated by Claude Code

SaveAsync recorded every command it wrote as persisted by this manager,
including stored commands it only carried through for another manager.
The next save then read those as unregistered here and dropped them from
commands.json, so a second save deleted the other manager's commands and
left their bindings dead. Record only the commands registered here, as
the profile path already does.

Fixes #214

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

sonarqubecloud Bot commented Nov 3, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 944a01c into main Nov 4, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the fix/214-persisted-command-ids branch November 4, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants