Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Add events to extension API to capture editor opened / editor closed #59159
At the moment there is no proper way of capturing that the user opened or closed a tab. You can capture whether they switched between tabs, and you can capture opens/closes of text documents, but not editors.
Note that the text document events aren't helpful here because they trigger any time you switch between files.
As a workaround I've noticed that when switching tabs the onDidChangeActiveTextEditor event is called before onDidCloseTextDocument. When closing a tab it's the inverse. You can use this information to infer whether a tab was closed or just switched, but that requires you to use some very error-prone timing.
This request is similar to but not the same as #15178
@jrieken with due respect I disagree. Not to say it cannot be solved the same way, but the linked ticket is requesting an API to retrieve a list of open editors whereas I'm requesting an API to listen for events for opened / closed editors. These are not the same things, though they can certainly address similar use-cases.
I would appreciate this issue be reopened or at least some clarification as to why this is a duplicate (eg. are you intending to address both requests under that one issue?).