Handle CustomTextEditor after opening

Viewed 34

I want to open a file with my custom text editor and after opening, the editor should scroll to a position given by an element id.

I use the vscode command vscode.commands.executeCommand('vscode.openWith', fileURI, EditorProvider.viewType); to open the file, but the command does not return the opened editor like showTextDocument.

Is there a way to open the file like the following example but with my custom editor?

vscode.workspace
        .openTextDocument(path)
        .then((textDocument) => {
            vscode.window.showTextDocument(textDocument, 2, false)
                .then((editor) => {
                    //scroll to element
                });

Or alternatively: Is there a possibility to pass on the element id and to handle the parameter after opening the file? Like this: vscode.commands.executeCommand('vscode.openWith', fileURI, EditorProvider.viewType, scrollToElement);

0 Answers
Related