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

reveal-option when opening a document #13639

Closed
alefragnani opened this issue Oct 13, 2016 · 6 comments
Closed

reveal-option when opening a document #13639

alefragnani opened this issue Oct 13, 2016 · 6 comments
Assignees
Labels
api *duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality

Comments

@alefragnani
Copy link

When you call showTextDocument you can pass in which column a TextDocument should be opened. It works perfectly if it being opened for the first time, but if that TextDocument was already opened before, on a different column, you may end up with two views of the same TextDocument.

I didn't find any API to check if the TextDocument is/was already opened, or any API to access the Stacks/Columns, so I could search for that TextDocument and detect the correct column to be used. I only found onDidChangeTextEditorViewColumn event, that appears to be a way to follow the changes.

Thanks for your help.

@jrieken
Copy link
Member

jrieken commented Oct 13, 2016

There is TextEditor.viewColumn and the list of visibileTextEditors with that you should be able to find what you need. Does that help?

@jrieken jrieken closed this as completed Oct 13, 2016
@jrieken jrieken added *question Issue represents a question, should be posted to StackOverflow (VS Code) api labels Oct 13, 2016
@alefragnani
Copy link
Author

Hi @jrieken ,

Thanks for your advice, but unfortunately it does not work, because it only returns the currently visible document in that column, not the list of documents.

I mean, let´s suppose I have two columns with 2 opened documents in each one, like the picture below. In this case the visible document in each column is the first one (LEFT - extension.test.ts / RIGHT - launch.json).

vscode_column

In my scenario, I'm currently focused in the LEFT column. If I need to reopen/navigate to the second one (package.json), which is in the RIGHT column, vscode.window.visibleTextEditors[X] gives me launch.json, with no information about package.json (at least no API), so I can't know that package.json is also stacked in that column. If I had access to the stacks, I could look for that file and open/focus it in the correct column.

The intention is to avoid reopen the same document twice, but instead navigate to the already opened instance.

Thanks for your help

@jrieken
Copy link
Member

jrieken commented Oct 14, 2016

Yes - we have not exposed the stacks/tab model but an editor in the API land is an editor widget that is bound to a model. I will think about some options for the show-call, like revealIfAlreadyOpenInColumn

@jrieken jrieken added feature-request Request for new features or functionality and removed *question Issue represents a question, should be posted to StackOverflow (VS Code) labels Oct 14, 2016
@jrieken jrieken changed the title How to know in which column a document is/was opened? reveal-option when opening a document Oct 14, 2016
@alefragnani
Copy link
Author

@jrieken thanks 👍

By the way, I guess you forgot to reopen the issue 😁

@jrieken jrieken reopened this Oct 17, 2016
@jrieken
Copy link
Member

jrieken commented Oct 17, 2016

I did ;-)

@jrieken
Copy link
Member

jrieken commented Apr 11, 2017

closing this as dupe of #15178 which came later but is a little easier to understand

@jrieken jrieken closed this as completed Apr 11, 2017
@jrieken jrieken added the *duplicate Issue identified as a duplicate of another issue(s) label Apr 11, 2017
@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
api *duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

2 participants