Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close TextDocument in VS Code?

I'm writing vscode extension.

I opened a TextDocument with vscode.window.showTextDocument, and want to close it later. But I can't find api to close it. Finally I found this commit, it removed closeTextDocument. What should I do now?

like image 601
blackmiaool Avatar asked Jun 24 '17 05:06

blackmiaool


People also ask

How do you close extensions in VS Code?

To uninstall an extension, select the Manage gear button at the right of an extension entry and then choose Uninstall from the dropdown menu. This will uninstall the extension and prompt you to reload VS Code.

How do you close the right side bar in VS Code?

Tip: You can move the Side Bar to the right hand side (View > Move Side Bar Right) or toggle its visibility (Ctrl+B).

How do I stop C code from running in VS Code?

First of all, we need to stop the background running the c program by pressing the Alt + Ctrl + M from the keyboard.


1 Answers

I encountered the same problem. The only way I managed to do it is via workbench.action.closeActiveEditor, as recommended by the inline documentation for TextEditor.hide.

It's hackish - basically show the document in the editor, then close the active editor:

vscode.window.showTextDocument(entry.uri, {preview: true, preserveFocus: false})
    .then(() => {
        return vscode.commands.executeCommand('workbench.action.closeActiveEditor');
    });
like image 138
Dan Ștefancu Avatar answered Sep 21 '22 09:09

Dan Ștefancu