Skip to content

Resolve a relative data directory once, for both the files and the lock [patch] - #220

Open
matt-edmondson wants to merge 1 commit into
mainfrom
fix/217-resolve-data-directory
Open

matt-edmondson wants to merge 1 commit into
mainfrom
fix/217-resolve-data-directory

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #217

What changed

JsonKeybindingRepository resolved its lock key with Path.GetFullPath in the constructor, but kept the relative path for every file operation. Once the current directory changed (for example after an OpenFileDialog without RestoreDirectory), saves went to a different folder and the rebind was lost on the next launch. The lock still guarded the original folder, so the #148 lost update came back too.

The constructor now resolves the trimmed directory once. That one absolute path is used for the files and for the lock. KeybindingManager, KeybindingManagerFactory and the DI extensions all build their storage through this constructor, so they are covered as well.

Tests

RelativeDataDirectoryTests is new. It is [DoNotParallelize] because it changes the process-wide current directory, and it restores it in cleanup.

  • A repository built from "data" under a/ saves, the current directory moves to b/, and it saves again. Both profiles are in a/data, and no b/data is created.
  • The manager scenario from the issue: bind Ctrl+C, save, change directory, rebind Ctrl+Shift+C, save, restart from a/. The rebind is there.
  • Two repositories built from one relative path under different current directories each write all 50 of their profiles to their own directory.

With the fix reverted, all three fail. With it, the full suite passes (384/384).

This may also settle #194, as the triage notes, but it doesn't claim to: the lock key there still depends on spelling (data vs data/, letter case).


Generated by Claude Code

…ck [patch]

JsonKeybindingRepository resolved its lock key with Path.GetFullPath at
construction but kept the relative path for every file operation, so after
the current directory changed a save went to another folder (and was lost on
the next launch) while the lock still guarded the original one. The
directory is now resolved once and that one path is used for both.

Fixes #217

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

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

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