fix: multi-cursor path insertion only updated the first cursor (#70)#82
Merged
Conversation
Selecting text with multiple cursors and inserting a relative path only updated the first cursor. The code opened one editor.edit() and then, for each selection, fired a separate editor.edit() in the same tick. VS Code allows only one active edit at a time, so every call after the first ran against a busy document and was dropped. Extract the replacement into replaceSelections(), which applies every selection on a single editBuilder inside one edit(). The helper uses structural typing instead of importing vscode so it is covered by unit tests under the repo's node --test harness. Closes #70 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
Selecting text with multiple cursors and inserting a relative path only updated the first cursor (issue #70).
Root cause
returnRelativeLinkopened oneeditor.edit()and then, inside its callback, fired a separateeditor.edit()for every selection in the same tick. VS Code allows only one active edit at a time, so every call after the first ran against a busy/stale document and was silently dropped.Fix
Extract the replacement into
replaceSelections(), which applies every selection on a singleeditBuilderinside oneedit()call. The helper uses structural typing instead of importingvscode, so it's covered by unit tests under the repo'snode --testharness (matching the other pure modules).Tests
test/replace-selections.test.ts: asserts exactly oneedit()call with one replacement per cursor, plus the single-cursor case.Closes #70
🤖 Generated with Claude Code