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

Add openedTextEditors, onDidOpenTextEditor, onDidCloseTextEditor to the extensions API #8886

Closed
ArtemGovorov opened this issue Jul 8, 2016 · 9 comments
Assignees
Labels
Milestone

Comments

@ArtemGovorov
Copy link
Contributor

ArtemGovorov commented Jul 8, 2016

  • VSCode Version: 1.3.0
  • OS Version: OSX

Our extension is rendering decorations in opened editors.

Extensions API has the window.visibleTextEditors, workspace.onDidOpenTextDocument, and workspace.onDidCloseTextDocument that allow to track opened documents and render the decorations in visible editors (and dispose things when the editor is not visible anymore).

Now with the new opened tabs feature, I thought it'd be good not to dispose the decorations if an editor wasn't closed but only became non-visible, but I couldn't find a way to do this with the current API version. I can track opened text documents, but there's no way to get an editor of the document and there's no window.openedTextEditors.

It would be great if the API was extended to include:

  • window.openedTextEditors,
  • window.onDidOpenTextEditor,
  • window.onDidCloseTextEditor.
@joaomoreno
Copy link
Member

cc @bpasero

@bpasero bpasero added the api label Jul 8, 2016
@jrieken jrieken added the feature-request Request for new features or functionality label Jul 12, 2016
@alexdima
Copy link
Member

Note: not visible editors are simply models not attached to a code editor widget. Extension Host decorations always go through a code editor widget and that one disposes decorations as soon as a model gets detached. In other words, if we expose non-visible editors it means we should reimplement how we handle extension host decorations.

@jrieken
Copy link
Member

jrieken commented Jul 12, 2016

That's what I meant.

@alexdima alexdima added this to the Backlog milestone Jul 12, 2016
@ChuckJonas
Copy link

is it at least possible to get the model information for all open editors? I have a use-case where I need to get the file path of all open tabs/editors.

@jrieken
Copy link
Member

jrieken commented Nov 8, 2016

@ChuckJonas Yes - there is window.visibleEditors which allows you iterate over all editors including their documents.

Also FYI everyone, we have added onDidChangeVisibleTextEditors which fires whenever the list of active editors changes

@alexdima alexdima removed their assignment Nov 8, 2016
@ChuckJonas
Copy link

@jrieken either you are mistaken about the behavior of window.visibleTextEditors or I am experiencing a bug. From what I can tell, window.visibleTextEditors only gives you editors that are currently in view.

Example:

Open Project
3 files are opened from my last sessions
I open 2 more

When I access window.visibleTextEditors I only see the currently opened editor and a log file. If I split screen, I now see both files and a long file.

There should be a way to get a list of everything that shoulds up in the open editors pane. I don't necessarily need an Editor instance, but need to be able get the file name.

@jrieken
Copy link
Member

jrieken commented Nov 8, 2016

Well, for extensions the following is true: open editor === visible editor. That fact that there are UX elements like Open Editors or editor tabs doesn't mean that there exists an editor for those documents nor does it mean those documents are already loaded - especially not after a restart. The data from the open editors pane has no representation in the API.

@ChuckJonas Curious to know what you are trying to do and why that requires access to the open editors data model?

@ChuckJonas
Copy link

@jrieken sure,
So I'm a contributor on a Extension used for Salesforce development. Code is compiled by pushing it to their tooling api (yes, it sucks horribly not to be able to compile locally).

So imagine you need to rename a class that is referenced in 5 other classes. You replace all occurrences of the symbol and want to compile it (basicly deploy it to a development instance). I must make a single request, with all 5 updated files in order for it to succeed.

You could deploy the whole project, that but might contain thousands of files, some of which could be out sync or even outright broken (and thus the compilation will fail).

The way this is handled by current IDE's is to allow the user to compile all open tabs.

Also,

I don't need an editor instances to do this, I just need the file paths.

@jrieken
Copy link
Member

jrieken commented Dec 9, 2016

Closing this because there is onDidChangeVisibleTextEditors. Access to open editors, that is the editor tab model, is tracked here: #15178

@jrieken jrieken closed this as completed Dec 9, 2016
@jrieken jrieken removed the feature-request Request for new features or functionality label Dec 9, 2016
@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
Projects
None yet
Development

No branches or pull requests

6 participants