Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onDidCloseTextEditor triggering on preview pane that is still open #14118

Closed
anthonydresser opened this issue Oct 20, 2016 · 4 comments
Closed
Assignees
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)

Comments

@anthonydresser
Copy link
Contributor

  • VSCode Version: 1.6.1
  • OS Version: OSX

Related to #13623 . From that I learned that preview panes (virtual documents) have a 3 minute timer that clean ups unused virtual files. However, it appears as though this is attempting to clean up documents that are not closed, but simply not currently visible.

Open preview panes

onDidCloseTextEditor triggering for a preview pane I have open

This is a problem because this means we can not trust this onDidCloseTextDocument event in order to know when to clean up data, meaning we have to hold on to data forever. Is this expected behavior? Is there a vscode.window.visibleTextEditors but for all open files so we can check to see if a html pane has actually been closed?

Steps to Reproduce:

  1. Open two html preview panes
  2. Wait for the three minute clean up to trigger and on did close document will trigger for a document you already have open but not visible.
@jrieken jrieken added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label Oct 21, 2016
@jrieken
Copy link
Member

jrieken commented Oct 21, 2016

Yeah - open is defined as visible in an editor/pane and not as visible as tab. The latter is just a UI gesture to quickly open/restore a document (the obvious case is after a refresh, when tabs are restored but not documents). Likewise a tab that you never come back to is like a closed editor. Whatever dispose strategy one implements it's a tradeoff.

Tho, it doesn't mean that you cannot trust the onDidCloseTextDocument event because that is never fired for a document currently showing (contents) and if fired on subsequent views we will ask to create the same document again.

@jrieken jrieken closed this as completed Oct 21, 2016
@anthonydresser
Copy link
Contributor Author

The problem is I need a way to know when the pane is actually closed so that I can properly clean up data that is no longer needed. Currently I have two options, just never clean up the data (which could have some pretty obvious performance problems);

Or clean up the data on this current close request and have to go through and re create the data when I get the open request from vscode again, which would be a bad user experience and could have undesired side effects for the user.

@rebornix
Copy link
Member

Run into the same issue as @anthonydresser with Vim.

open is defined as visible in an editor/pane and not as visible as tab.

Previous I didn't know that we define open in above way so we clear our internal cache for buffer each time a text document is closed. It works perfectly while just opening files but it started to fail if you work on a project with language service enabled, for example, a valid TypeScript project. Each time when we switch tabs, the text document is closed and then definitely we'll clear all internal cache (like marks, macros, etc) and reinitialize it when we switch to the tab again.

@xconverge
Copy link
Contributor

I was under the impression that onDidTextDocumentClose meant the tab was closed...not just switched away from...

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)
Projects
None yet
Development

No branches or pull requests

4 participants