Skip to content

An API to open a markdown preview as a "preview editor" to the side (AKA Italic tab title) #154145

@AddieCohen

Description

@AddieCohen

We are trying in our extension to open a Markdown preview to the side (A second editor group), but as a "preview editor" (AKA Italic tab title) that will get replaced should a user choose to open another Markdown file/preview afterwards. Yet we couldn't figure out a way to get this to work. We have tried the following:

  • The markdown.showPreviewToSide command adds a new tab to the editor group each time it runs (And doesn't open it as a "preview editor", the markdown.showPreview commands open in the current editor group but does replace a previously opened Markdown file/preview, yet isn't a de-facto "preview editor" (The tab title is not in italic), so the logic for replacing it might be a custom implementation inside the built-in Markdown extension.

  • vscode.openWith allows to open a Markdown tab as a custom editor rather than a webview panel, yet it ignores the preview/pinned flag, always defaulting it to not open as preview.

    return editorService.openEditor({ resource: URI.revive(resource), options: { ...optionsArg, pinned: true, override: id } }, group);

  • Trying to manually kludge such behavior using vscode.window.tabGroups, but it is async with the API to actually open an editor, and it is difficult to match the exact tab that we just opened from the information available in the callback, we can only match on the tab title which seems very very brittle.

We would love there to be an API that makes it easy to do this, so we can make our extension's sidebar open the Markdown preview in "preview" mode and behave in a similar way to clicking on files in the built-in file explorer.

P.S. The API for opening a web view panel doesn't even support a flag to open it as a preview editor, unlike the API for opening text editors.

Metadata

Metadata

Assignees

Labels

*out-of-scopePosted issue is not in scope of VS Codeapifeature-requestRequest for new features or functionalitymarkdownMarkdown support issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions