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

OnDidCloseTextDocument taking upwards of 60 seconds to trigger #114005

Closed
davidkjackson54 opened this issue Jan 7, 2021 · 3 comments
Closed

OnDidCloseTextDocument taking upwards of 60 seconds to trigger #114005

davidkjackson54 opened this issue Jan 7, 2021 · 3 comments
Assignees
Labels
*as-designed Described behavior is as designed

Comments

@davidkjackson54
Copy link

davidkjackson54 commented Jan 7, 2021

I have a VSCode extension and I need to know when a file is saved and closed so I Can take a follow on action.

  • VSCode Version: 1.52
  • OS Version: Windows 10

Steps to Reproduce:
As a simple test, I have this defined in my extension.ts

vscode.workspace.onDidCloseTextDocument((doc) => {
    console.log("Closed", doc);
  });

I then run my extension and open a file in the editor window. I then close that file's tab.
I then sit and wait and do nothing.
It is taking upwards of between 60 and 90 seconds before the console log message appears with the result. What is being displayed is correct but the delay of over a minute makes it unusable.

Capture

Is there a solution to this or is this a defect?

I am aware of the reference in the doc to this comment:
Note 1: There is no guarantee that this event fires when an editor tab is closed, use the onDidChangeVisibleTextEditors-event to know when editors change.

However - that then begs the question as to what then is the purpose of OnDidCloseTextDocument if it doesn't do what it says on the tin! ??? It works but takes 60+ seconds to respond.
Whereas the suggestion of using onDidChangeVisbibleTextEditors doesn't provide any useful info telling you exactly what file/tab was closed. I don't see that it comes even close to what OnDidCloseTextDocument is accomplishing albeit taking an age to actually notify the event..

I am also aware of this similar reported problem.
#102737

How it can be possibly considered to be working as designed seems very strange as in its current form it is unusable.
I close an editor tab of a file that has been editted. I would expect to be notified immediately that it is closed. I do not see that as being unreasonable when the event is titled OnDidCloseTextDocument.

If this has no plan to be addressed, what is the correct method of determining that a tab of a file that has been changed is now closed as OnDidChangeVisibileTextEditors does not provide that capability.

@jrieken jrieken added the *as-designed Described behavior is as designed label Jan 8, 2021
@jrieken
Copy link
Member

jrieken commented Jan 8, 2021

If this has no plan to be addressed, what is the correct method of determining that a tab of a file that has been changed is now closed as OnDidChangeVisibileTextEditors does not provide that capability.

Currently there is no representation for editor tabs (aka the open editor model) in the API. You will find a tracking issue for what searching of "open editors api"

@davidkjackson54
Copy link
Author

davidkjackson54 commented Jan 8, 2021

A number of people appear to have reported this shortcoming. Is it planned to provide this functionality to Extensions? The event is titled - OnDidCloseTextDocument - and it isn;'t.
It might be working as 'expected' but isn't working as most folk require.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed
Projects
None yet
Development

No branches or pull requests

3 participants
@jrieken @davidkjackson54 and others