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
Documents opened using window.showTextDocument send a delayed didClose event to LSP #201294
Reopening the file does not resend a didOpen request and closing the tab does not send a didClose - so it must be that (for some reason) closing the file is delayed significantly. After waiting for 5 minutes, a didClose is actually emitted but it is very strange that using the commands API it is more predictable and interactive than the window API
changed the title [-]Documents opened using `window.showTextDocument` do not emit `didClose` event to LSP[/-][+]Documents opened using `window.showTextDocument` send a delayed `didClose` event to LSP[/+]on Dec 20, 2023
We closed this issue because it is a question about using VS Code rather than an issue or feature request. Please search for help on StackOverflow, where the community has already answered thousands of similar questions. You may find their guide on asking a new question helpful if your question has not already been asked. See also our issue reporting guidelines.
This is as designed and documented. The editor decides when to close a document by its own rules. Note that document !== editor !== tab and if you wanna track tab changes you should use the corresponding APIs
The editor decides when to close a document by its own rules.
I understand that but it seems there is inconsistency between using window.showTextDocument and commands.executeCommand("vscode.open"). For example, if you open a file from the explorer and close it, an event is emitted immediately which is the desired behavior and matches the documents opened using the commands API but not the window API. The docs do not cover such cases (https://code.visualstudio.com/api/references/commands)
Let me describe the user case:
A language server performs more thorough validation for open documents vs files that are in the project. When using the command API, an editor is opened, the server reports a number of diagnostics and the user can perceive this as related to their own interaction with VS code. If they close the document, the regular validations are restored and the additional feedback diagnostics disappear - also perceived as a reaction to the user input.
With the window API, it's not possible anymore for the user, to understand the changed number of diagnostics "a while after the user interaction" based on the editors "own rules". This is not related to tab handling or anything.
Johannes Rieken (@jrieken) Do you understand the use case and if so, can you confirm that the UX is inferior with the window.showTextDocument behavior compared to exectureCommand?
The language server is implemented for different front ends. I don't feel like replicating everything that's already handled by didOpen and didClose. What is the advantage of doing a client-specific implementation?
I don't feel like replicating everything that's already handled by didOpen and didClose.
Well, isn't the whole point of this discussion that not every is handled via didOpen and didClose and that you are using the wrong tool for the job. There is more shortcomings with your approach
didOpen is fired when ctrl+hovering
didOpen is fired when an extension uses the openTextDocument (which is !== showTextDocument)
didOpen is usually fired for every file another time because for quick diff'ing an original version of the document is tracked
didOpen is not fired for tabs after restore/reload
didClose is fired based on ref-counting, timeout and memory pressure strategies
etc pp
What is the advantage of doing a client-specific implementation?
Activity
[-]Documents opened using `window.showTextDocument` do not emit `didClose` event to LSP[/-][+]Documents opened using `window.showTextDocument` send a delayed `didClose` event to LSP[/+]vscodenpa commentedon Dec 20, 2023
We closed this issue because it is a question about using VS Code rather than an issue or feature request. Please search for help on StackOverflow, where the community has already answered thousands of similar questions. You may find their guide on asking a new question helpful if your question has not already been asked. See also our issue reporting guidelines.
Happy Coding!
jrieken commentedon Dec 20, 2023
This is as designed and documented. The editor decides when to close a document by its own rules. Note that document !== editor !== tab and if you wanna track tab changes you should use the corresponding APIs
EhabY commentedon Dec 20, 2023
I understand that but it seems there is inconsistency between using
window.showTextDocumentandcommands.executeCommand("vscode.open"). For example, if you open a file from the explorer and close it, an event is emitted immediately which is the desired behavior and matches the documents opened using the commands API but not thewindowAPI. The docs do not cover such cases (https://code.visualstudio.com/api/references/commands)szarnekow commentedon Dec 20, 2023
Let me describe the user case:
A language server performs more thorough validation for open documents vs files that are in the project. When using the command API, an editor is opened, the server reports a number of diagnostics and the user can perceive this as related to their own interaction with VS code. If they close the document, the regular validations are restored and the additional feedback diagnostics disappear - also perceived as a reaction to the user input.
With the window API, it's not possible anymore for the user, to understand the changed number of diagnostics "a while after the user interaction" based on the editors "own rules". This is not related to tab handling or anything.
Johannes Rieken (@jrieken) Do you understand the use case and if so, can you confirm that the UX is inferior with the window.showTextDocument behavior compared to exectureCommand?
jrieken commentedon Dec 20, 2023
Ehab Younes (@EhabY) Sebastian Zarnekow (@szarnekow) Why are you not using the tabs API (
vscode.window.tabGroups) which was built specifically with diagnostics in mindszarnekow commentedon Dec 20, 2023
The language server is implemented for different front ends. I don't feel like replicating everything that's already handled by didOpen and didClose. What is the advantage of doing a client-specific implementation?
jrieken commentedon Dec 20, 2023
Well, isn't the whole point of this discussion that not every is handled via didOpen and didClose and that you are using the wrong tool for the job. There is more shortcomings with your approach
openTextDocument(which is !==showTextDocument)You have something that works better
fix: handle tabs events by LS client
fix: handle tabs events by LS client
fix: handle tabs events by LS client