Skip to content

fix(rename): wait for the host before asking for edits - #137

Merged
BartvHelvert merged 2 commits into
masterfrom
fix/rename-stale-mirror
Nov 9, 2026
Merged

BartvHelvert merged 2 commits into
masterfrom
fix/rename-stale-mirror

Conversation

@BartvHelvert

Copy link
Copy Markdown
Owner

What this changes

In-place rename could apply an extension's edit to the wrong text when the IDE was busy. Seen in PR #135's CI: renaming value to renamed in let value=1; / value; gave let renamed; / value;.

When the rename's template finishes, it puts the old name back and asks the extension for the real edit. The extension works on its own copy of the document. The rename waited at most 2 s (awaitMirrored's default) for that copy to hold the name put back, and asked anyway when it had not. That runner logged a 5.5 s UI freeze. The extension still held let renamed=1;, so its edit replaced the 7-character word at [4,11). By the time it was applied, the editor was back to let value=1;, so the edit replaced value=1. The check before applying passed: by then the text had been sent, and a rename edit carries no document version.

The rename now waits up to 30 s, under its own cancellable progress dialog, for the extension's copy to hold the text the edit will be applied to. If it never does, nothing is renamed and a hint says so. Every other caller of awaitMirrored already gave up on a host that had not caught up; rename was the only one that ignored the result.

Fixes #136

How it was tested

  • New RenameTest case, the extension is asked only once its copy holds the name put back: the host's copy still holds the typing when the template finishes and catches up after 3 s, past the old 2 s wait. It passes with the fix. With the old behavior put back temporarily it fails: the rename never ends up as call total.
  • All 10 RenameTest cases pass.
  • Full suite, one freshTest -PsearchableOptions=false --continue run: 1,514 tests, 0 failures, 0 errors, 3 skipped. The test tasks were executed, not taken from the build cache.
  • The UI test that failed (SplitModeActionsTest) was not run locally. This PR's CI runs it on Windows and Ubuntu. The race is intermittent, so one green run doesn't prove it fixed.

Checklist

  • Nothing is special-cased for one extension.
  • A new feature has a UI test. Bug fix; a backend regression test was added, and the existing UI test covers the flow.
  • No internal, override-only, obsolete or deprecated platform API.
  • docs/ is updated where behaviour changed, docs/status.md especially. No documented behaviour changed.
  • Third-party material keeps its notice and is listed in NOTICE.md. None added.

In-place rename puts the old name back when its template finishes,
then asks the extension for the edit. It waited at most two seconds
for the host's copy to hold that text, then asked anyway. On a busy
machine the host still held the typed name: its edit, worked out for
that text, replaced the wrong characters, and the occurrences it did
not find kept the old name. Wait as long as the rename's cancellable
progress shows, and rename nothing if the host never catches up.

Refs #136
The stale-host test took the host to be behind until its own thread
updated it. On CI another test in the shared project had started the
language servers, whose document listener mirrors the name put back
straight away, so the extension was correctly asked early and the test
failed. Check that the host's copy is the editor's when the edit is
asked for, and join the delayed update so it never outlives the test.

Refs #136
@BartvHelvert
BartvHelvert merged commit e908d3e into master Nov 9, 2026
8 checks passed
@BartvHelvert
BartvHelvert deleted the fix/rename-stale-mirror branch November 9, 2026 19:40
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.

In-place rename can apply an extension's edit to the wrong text when the IDE is busy

1 participant