How to open Custom Editor with VSCode api

Viewed 1051

I have an extensions that registers a CustomEditorProvider for a specific file type and I need to create a command that opens a given file with my editor.

If i click on the file from the workspace explorer my editor opens correctly but if I use the showTextDocument api the built-in text editor will open.

private openModule(file:vscode.Uri) {
    vscode.workspace.openTextDocument(file).then((doc: vscode.TextDocument) => {
          vscode.window.showTextDocument(doc);
    });
  }

On the opened editor in the UI I can "Reopen Editor With..." that prompts me with the selection of the editor. And I if select my custom editor it will be reopened with the correct editor.

Editor provider selection

How do I force the TextEditor to use the custom one and not the build in?

Any help is appreciated

1 Answers
Related