Repository navigation
fix: a file whose editor moves to another window stays open in its language servers, which no longer get didClose while an editor of the file remains - #2212
Merged
lagergren merged 2 commits intoNov 24, 2026
Conversation
…nguage servers, which no longer get didClose while an editor of the file remains Dragging an editor tab into another window, a detached one included, or moving it to the opposite tab group closes the editor before the platform opens the file again in the other window; a drop into a detached window opens it only later, in a coroutine. The file was in no editor at the close, so its language servers got didClose, and didOpen again only once a feature asked for the file. In between, they worked without the document. The platform marks such a close with CLOSING_TO_REOPEN. A marked close now neither disconnects the file nor counts as a close of its last editor. Closing a file in one tab group also no longer sends didClose while the file stays open in another one whose editor of it the platform is still creating, as right after a split. The file listener looked only at the editors of the file, of which that tab group has none yet, while the setup participant already checked that the file is open. Fixes redhat-developer#1383
… or tab group, and gets one didClose when its last editor closes The real editor manager replaces the test one, which has no windows. A detached window is a frame, which a headless test can't create, so another tab group of the main window stands in for it: the editor manager treats both alike. The tests cover a file open in two tab groups, closed in the first right after the split; the platform's Move to Opposite Group action; and the end of a tab drag into another window, whose drop opens the file after the drag has ended.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2212 +/- ##
==========================================
+ Coverage 54.59% 54.66% +0.06%
==========================================
Files 834 834
Lines 35385 35388 +3
Branches 7300 5547 -1753
==========================================
+ Hits 19320 19344 +24
+ Misses 13223 13204 -19
+ Partials 2842 2840 -2 ☔ 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 was referenced Nov 25, 2026
lagergren
added a commit
that referenced
this pull request
Nov 26, 2026
The plugin verifier reported `FileEditorManagerImpl` and its field `CLOSING_TO_REOPEN` as internal API usages on all eight verified IDEs, 2024.2 to 2026.3, from `ConnectDocumentToLanguageServerSetupParticipant.isClosingToReopen` (1a0dca5, #2212). No public field has the key on every supported version: - `FileEditorManagerImpl` is `@ApiStatus.Internal` on all of them. - `FileEditorManagerKeys.CLOSING_TO_REOPEN` is public from 2024.3 on, but `FileEditorManagerKeys` is missing in 2024.2, the minimum. - No public editor event tells a close to reopen apart: at the end of a tab drag, the platform sets the marker, closes the editor and only then drops it into the target, which for a detached window opens the file later, in a coroutine. So `isClosingToReopen` finds the platform's key by its name, with `Key.findKeyByName("CLOSING_TO_REOPEN")`, and keeps it once found. It's the same key on every supported version: from 2024.3, `FileEditorManagerImpl.CLOSING_TO_REOPEN` is `FileEditorManagerKeys.CLOSING_TO_REOPEN`, and no other platform key has the name. It's a workaround, and `findKeyByName` is deprecated, not internal, so the verifier reports one deprecated usage instead of two internal ones. Once the minimum version has `FileEditorManagerKeys`, `isClosingToReopen` can read it instead (#1971). The key exists once the platform's editor manager is loaded, before any editor closes. Until it's found, as with the editor manager of a test, no file has the marker, and the lookup is tried again at the next close. `EditorWindowConnectionTest` gets a test that the marker which the platform's editor manager sets is the one that LSP4IJ reads. With a wrong key name, it fails, and so do the tests of the move to the opposite tab group and of the drag into another window. Part of #2274
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 #1383
What
Dragging a file's editor tab into another window (detached or not), or using Move to Opposite Group, made LSP4IJ send
didClosefor the file. It sentdidOpenagain only when a feature next asked for the file, so in between the language server worked without the document. Closing a tab right after a split also sentdidClosewhile the file stayed open.Cause
At the end of a tab drag, the platform (
EditorTabbedContainerDragOutDelegate.dragOutFinished, the same on 2024.2, 2025.3 and 2026.3):CLOSING_TO_REOPENon the file;fileClosedwhile the file is in no editor;DockableEditorTabbedContainer.addopens it later, in a coroutine, after the marker has been cleared.So
LSPFileListener.fileClosedfound no editor and disconnected the file. Move Editor to Opposite Tab Group does the same close-then-reopen, with the same marker.Right after a split, the new tab group already has the file open (
isFileOpen), but it creates its editor asynchronously, sogetAllEditors(file)is empty for a moment. Closing the original tab then sentdidClosetoo.Change
ConnectDocumentToLanguageServerSetupParticipant.isClosingToReopen(file)reads the platform'sCLOSING_TO_REOPENmarker, as the platform's ownfileClosedlisteners do, such asScratchFileServiceImplandQuickEditHandler. While it's set:LSPFileListener.fileCloseddoesn't disconnect the file;LSPFileListener.fileClosedalso keeps the file connected whilesource.isFileOpen(file)is true, as the setup participant's close count already does.API: the marker is read from
FileEditorManagerImpl.CLOSING_TO_REOPEN, which is@ApiStatus.Internaland deprecated from 2025.3, where it points toFileEditorManagerKeys.CLOSING_TO_REOPEN.FileEditorManagerKeysdoesn't exist in 2024.2, so that's the reference that compiles on all supported versions. The deprecation is suppressed in that one method. The plugin verifier reports it as an internal API usage, which doesn't fail verification (failureLevelisINVALID_PLUGINandCOMPATIBILITY_PROBLEMS). Once the minimum is 2025.3 or later, it can readFileEditorManagerKeysinstead (#1971).Not in this PR:
Tests
New
EditorWindowConnectionTest(3 tests). It uses the realFileEditorManagerImplinstead of the test editor manager, which has no windows. Each test checks what the mock language server actually read, with adidSavesent after the editors change. It then closes the last editor and expects exactly[didOpen, didClose].A detached window is a frame, which can't be created headless, so a second tab group of the main window stands in for it. The editor manager handles both alike.
Red-green on 2024.2:
[didOpen, didClose, didOpen]*Document*,LanguageServer*,ChangeDuringConnectionTest,ConnectDuringStopTest,WorkspaceDiagnosticsTest,KeepAliveDuringPendingStopTest,ServerStopPendingRequestsTestand more) pass on all three platforms: 350 tests each, with 0 failures or skipped.Behaviour change
didClose, anddidOpencomes back only when a feature asks for the file; closing a tab right after a split sendsdidClosewhile the file stays opendidOpen, and onedidClosewhen its last editor closes