Home > other >  Disable preview for vscode custom text editor extension
Disable preview for vscode custom text editor extension

Time:12-24

Is there a way to disable the preview mode for my custom text editor without changing the user settings (workbench.editor.enablePreview: false)?

Like it can be done with vscode.window.showTextDocument() and vscode.workspace.TextDocumentShowOptions were you can set preview: false.

CodePudding user response:

I didn't see anything helpful in the extension api. So here is a possible workaround. I assume you can listen for when your custom editor is being opened - and then run this code:

await vscode.commands.executeCommand('workbench.action.keepEditor');

after it is opened. That should take it out of preview mode. It may be the best you can do.

  • Related