Repository navigation
fix: apply the will* edit to a loaded document that the server hasn't opened - #2137
Merged
lagergren merged 1 commit intoNov 23, 2026
Conversation
… opened Fixes redhat-developer#2135 A rename or move made in the IDE dropped the server's workspace/willRenameFiles edit if it changed a file that IntelliJ had loaded but the server hadn't opened, logging "Discarding stale workspace/will* edit: target document(s) modified during request" though no document had changed. captureDocumentStamps() records only the documents that the server has open, and isDocumentStale took any other target document that has a cached document for stale. A file that isn't open in an editor has one once anything has loaded it, so the edit was dropped for the files that a rename's edit is usually for. Such a document is now stale only if it has unsaved changes: the server, which didn't have it open, bases its edit on the file on disk, which the document matches unless it has unsaved changes. The recorded stamps still decide for the documents that the server has open. DocumentStampValidationTest's test of the old rule is now two tests, one for each case. Not changed: a document that the server hadn't opened, and that changes and is saved again during the request, still gets the edit. FileOperationRefactoringTest and FileOperationEditSaveTest get a test each that loads the other file's document before a rename: through RenameProcessor, and through a VFS rename. On main both fail: the edit is dropped.
lagergren
force-pushed
the
fix/apply-will-file-edits-to-unopened-documents
branch
from
November 23, 2026 13:04
a370775 to
fb5ecd8
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2137 +/- ##
==========================================
- Coverage 53.16% 53.15% -0.02%
==========================================
Files 826 826
Lines 34679 34679
Branches 5414 5414
==========================================
- Hits 18438 18434 -4
- Misses 13471 13476 +5
+ Partials 2770 2769 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
Author
|
@coderabbitai review |
Action not completed
|
Collaborator
Author
|
@coderabbitai review |
Action performed
|
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.
Fixes #2135
What
A rename or move made in the IDE dropped the server's
workspace/willRenameFilesedit whenever the edit changed a file that IntelliJ had loaded but the server hadn't opened. It loggedDiscarding stale workspace/will* edit: target document(s) modified during request, though no document had changed. The file was renamed, and its references in the other files kept the old name.Cause
AbstractLSPFileListener.captureDocumentStamps()records a stamp only for the documents that the server has open.isDocumentStaletreated a target document without a recorded stamp, but with a cached document, as stale.A file that isn't open in an editor still has a cached document once anything has loaded it, such as an editor opened and closed before, or Find Usages. So the edit was dropped for exactly the files that a rename's edit is usually for.
Change
isDocumentStaletreats a document without a recorded stamp as stale only if it has unsaved changes (FileDocumentManager.isDocumentUnsaved):The recorded stamps still decide for the documents that the server has open. Both paths use the check: the requests sent before a refactoring's write action (#1755), and those sent from the VFS listener.
Behavior changes
DocumentStampValidationTest.testNewlyOpenedDocumentIsStaletested the old rule. It is now two tests:testUntrackedDocumentWithoutUnsavedChangesIsNotStale;testUntrackedDocumentWithUnsavedChangesIsStale.Not changed
A document that the server hadn't opened, and that changes and is saved again while the request is out, still gets the edit: its document again matches the file on disk. Closing that gap would mean recording the documents that the server hasn't opened as well.
Test
New tests:
FileOperationRefactoringTest.testRenameRefactoringAppliesTheEditToALoadedDocumentThatTheServerHasNotOpenedloads the other file's document, then renames a file withRenameProcessor.FileOperationEditSaveTest.testWillRenameEditToALoadedDocumentThatTheServerHasNotOpenedIsApplieddoes the same with a VFS rename, and checks that the edit is saved.On
mainboth fail: the edit is dropped, and the other file keeps its text.testUntrackedDocumentWithoutUnsavedChangesIsNotStaleonmainFileOperation*,FileRenameUriTest,FileDocumentMoveTestandfeatures.files.*with the change