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

No API for closing inactive TextEditors #38239

Closed
rchande opened this issue Nov 13, 2017 · 5 comments
Closed

No API for closing inactive TextEditors #38239

rchande opened this issue Nov 13, 2017 · 5 comments
Assignees
Labels
api *duplicate Issue identified as a duplicate of another issue(s) under-discussion Issue is under discussion for relevance, priority, approach

Comments

@rchande
Copy link

rchande commented Nov 13, 2017

Looking at the docs for TextEditor (https://code.visualstudio.com/docs/extensionAPI/vscode-api#TextEditor) the Hide method has been deprecated. Per the documentation, its replacement is workbench.action.closeActiveEditor, which only closes the currently visible TextEditor tab.

There is (apparently) no supported way to close inactive TextEditors. Would it be possible to add such an API back?

(User scenario:
Omnisharp-Roslyn is adding support for CodeActions that rename files. When a file is renamed on disk, that's open in VS Code, Code keeps open the tab for the old file name but adds "Deleted" to the tab title. Omnisharp-Roslyn would like to close editor for renamed files. With the current APIs, there's no good way for us to close files that get renamed unless they are the active editor)

@vscodebot vscodebot bot added the api label Nov 13, 2017
@alexdima alexdima assigned jrieken and unassigned alexdima Nov 14, 2017
@jrieken jrieken added the under-discussion Issue is under discussion for relevance, priority, approach label Nov 14, 2017
@jrieken
Copy link
Member

jrieken commented Nov 14, 2017

There is (apparently) no supported way to close inactive TextEditors. Would it be possible to add such an API back?

For the API an inactive editor doesn't exist, only the combination of a document and editor widget is an API-editor. That's also why the hide method is deprecated. It will kill the editor-instance you are using it with.

Your use-case sounds similar to #10659 which is about adding a rename file to the WorkspaceEdit.

When a file is renamed on disk, that's open in VS Code, Code keeps open the tab for the old file name but adds "Deleted" to the tab title.

Yeah, that's not very nice... We should really offer a rename for this. @bpasero Is there anything today extensions can do to prevent this?

@bpasero
Copy link
Member

bpasero commented Nov 15, 2017

@rchande @jrieken that is only true when "workbench.editor.closeOnFileDelete": false is configured, which is not the default. A rename on disk is a delete of the old file and add of the new file. There is no watcher I know of that can reliably report a rename event with old and new path...

@rchande
Copy link
Author

rchande commented Nov 15, 2017

@bpasero I noticed the "deleted" text behavior when implementing OmniSharp/omnisharp-roslyn#1023. In that PR, Omnisharp will delete files on disk if Roslyn CodeActions rename them. I had the default value for that option and still saw the text show up. Do you know if any bugs were fixed in this area lately?

@rchande
Copy link
Author

rchande commented Nov 15, 2017

@jrieken Put differently: what API can I call to close a tab that is not the currently open tab? If there's no such API, consider this a request for it 😄 .

@jrieken
Copy link
Member

jrieken commented Nov 16, 2017

consider this a request for it

It's this #15178. But what you want is #10659 which is about the data model. A rename code action shouldn't care about UI state. Closing this as a dupe.

@jrieken jrieken closed this as completed Nov 16, 2017
@jrieken jrieken added the *duplicate Issue identified as a duplicate of another issue(s) label Nov 16, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 31, 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) under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

4 participants