You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A rename or move made in the IDE drops the server's willRenameFiles edit to a file that IntelliJ has loaded but the server hasn't opened #2135
When a file is renamed or moved in the IDE, LSP4IJ asks the language server for workspace/willRenameFiles and applies the edit it returns, such as the references to the renamed file. It drops that edit if the edit changes a file that IntelliJ has loaded but the server hasn't opened. It logs:
WARN - com.redhat.devtools.lsp4ij.features.files.AbstractLSPFileListener - Discarding stale workspace/will* edit: target document(s) modified during request
No document changed during the request. The file is renamed, and its references in the other files keep the old name.
A file that isn't open in an editor still has an IntelliJ document once anything loads it, for instance:
opening it in an editor and closing it;
an earlier refactoring or Find Usages;
a plugin that reads it.
So the edit is often dropped for exactly the files that a rename's edit is for: the other files, not open in an editor.
Steps
A language server that answers workspace/willRenameFiles with an edit to another file, such as a type's references when its file is renamed.
Open that other file in an editor, then close it. IntelliJ keeps its document.
Rename the first file in the Project view.
The file is renamed, the other file keeps its text, and the log has the warning above.
Expected
The edit is applied. The server read the other file from disk, since it didn't have the file open, and the document still matches the file on disk.
captureDocumentStamps() records a stamp for each document that the server has open (getOpenedDocuments()).
isDocumentStale(uri, doc, stamps) treats a target document that has no recorded stamp but has a cached document as stale: "Document was not open when stamps were captured but is now cached; we cannot verify the server's assumptions about its content."
For a document that the server didn't have open, though, the server's assumption is the file on disk. A document without unsaved changes matches it. The check came with #1695, and #1755's requests from before the refactoring's write action use it too. DocumentStampValidationTest.testNewlyOpenedDocumentIsStale tests this case.
Suggested fix
In isDocumentStale, treat a document without a recorded stamp as stale only if it has unsaved changes (FileDocumentManager.isDocumentUnsaved). An edit to such a document is based 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.
Activity
Register UP84, and the removal gates of the bridges kept since the 0.…
fix: apply the will* edit to a loaded document that the server hasn't…
fix: apply the will* edit to a loaded document that the server hasn't…
Register UP84, and the removal gates of the bridges kept since the 0.…
Register UP84, and the removal gates of the bridges kept since the 0.…
Register UP84, and the removal gates of the bridges kept since the 0.…
Register UP84, and the removal gates of the bridges kept since the 0.…
Register UP84, and the removal gates of the bridges kept since the 0.…
Register UP84, and the removal gates of the bridges kept since the 0.…
Register UP84, and the removal gates of the bridges kept since the 0.…