Skip to content

fix: multi-cursor path insertion only updated the first cursor (#70)#82

Merged
dawsbot merged 1 commit into
masterfrom
fix/multi-cursor-issue-70
Jul 7, 2026
Merged

fix: multi-cursor path insertion only updated the first cursor (#70)#82
dawsbot merged 1 commit into
masterfrom
fix/multi-cursor-issue-70

Conversation

@dawsbot

@dawsbot dawsbot commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Problem

Selecting text with multiple cursors and inserting a relative path only updated the first cursor (issue #70).

Root cause

returnRelativeLink opened one editor.edit() and then, inside its callback, fired a separate editor.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 single editBuilder inside one edit() call. The helper uses structural typing instead of importing vscode, so it's covered by unit tests under the repo's node --test harness (matching the other pure modules).

Tests

  • New test/replace-selections.test.ts: asserts exactly one edit() call with one replacement per cursor, plus the single-cursor case.
  • Written test-first (verified failing, then passing). Full suite: 33 passing.

Closes #70

🤖 Generated with Claude Code

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>
@dawsbot dawsbot merged commit bd0fd9a into master Jul 7, 2026
@dawsbot dawsbot deleted the fix/multi-cursor-issue-70 branch July 7, 2026 05:14
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.

Bug: Does not work when using multiple cursors

1 participant