Repository navigation
fix(rename): wait for the host before asking for edits - #137
Merged
Merged
Conversation
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
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.
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
valuetorenamedinlet value=1;/value;gavelet 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 heldlet renamed=1;, so its edit replaced the 7-character word at [4,11). By the time it was applied, the editor was back tolet value=1;, so the edit replacedvalue=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
awaitMirroredalready 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
RenameTestcase,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 ascall total.RenameTestcases pass.freshTest -PsearchableOptions=false --continuerun: 1,514 tests, 0 failures, 0 errors, 3 skipped. The test tasks were executed, not taken from the build cache.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
A new feature has a UI test.Bug fix; a backend regression test was added, and the existing UI test covers the flow.No documented behaviour changed.docs/is updated where behaviour changed,docs/status.mdespecially.Third-party material keeps its notice and is listed inNone added.NOTICE.md.