Change:
Issue Type: <bBug</b! When using the Markdown preview, the "Show Source" action should be smart enough to know that the source is open and go to that tab. Same applies to the preview tab, if there is already a preview tab open switch focus there. Otherwise you're in this endless loop of creating duplicate tabs. VS Code version: Code - Insiders 1.35.0-insider (, 2019-05-20T05:15:57.974Z) OS version: Darwin x64 18.2.0 <details<summarySystem Info</summary </details<details<summaryExtensions (30)</summaryExtensionVersion ------ vscode-browser-preview0.5.4 vscode-opennewinstance0.0.6 bracket-pair-colorizer1.0.61 vscode-svgviewer2.0.0 vscode-eslint1.9.0 gitlens9.7.4 vsc-material-theme2.8.2 prettier-vscode1.9.0 azure-virtual-machine-explorer0.0.2 vscode-pull-request-github-insiders1.137.0 vscode-colorize0.8.10 theme-monokai-pro-vscode1.1.13 vscode-azureappservice0.14.0 python2019.4. remote-containers0.53.0 remote-ssh0.37.0 remote-ssh-edit0.37.0 remote-ssh-explorer0.37.0 remote-wsl0.36.0 azure-account0.8.4 azurecli0.4.5 vscode-typescript-tslint-plugin1.0.0 debugger-for-chrome4.11.3 vetur0.21.0 vscode-docker0.6.2 vscode-yaml0.4.0 code-settings-sync3.2.9 ayu0.18.0 WebTemplateStudio-dev-nightly0.0. markdown-all-in-one2.3.1 (17 theme extensions excluded) </details<!-- generated by issue reporter --
I'd like to give this a try
Ok, I could use some help on this issue. I traced the click call to the function , but am not sure if I should be making any changes here since it will very likely affect other functionalities as well. I also noticed that if I have the file already open in the same split window pane, it will open that instead of creating a new split pane, but it is even when it opens a new pane with a new tab. So I am confused how calling the same function with the same parameter exhibits different behaviors (opening a new pane with a new tab vs opening an already open tab in the same pane). ! Some pointers around this would be very helpful, thanks
sorry for tagging you, not sure if you got a chance to see my previous comment. Can you please help out?
The api you linked to is a good starting point but that is part of core VS Code. You want the caller of that api, which in the case is the markdown extension. How I think this feature should work: the markdown extension, we maintain a . These should track which column created the preview. This is likely already passed in with , we just don't store the resourceColumn anywhere as far as I remember. the is invoked, use the preview's column information to decide which column to show the preview in

Discussion:
) { } public execute() { <del> if (this.previewManager.activePreviewResource) { return vscode.workspace.openTextDocument(this.previewManager.activePreviewResource) .then(document => vscode.window.showTextDocument(document)); </del> <ins> const { activePreviewResource, activePreviewResourceColumn } = this.previewManager; if (activePreviewResource && activePreviewResourceColumn) { return vscode.workspace.openTextDocument(activePreviewResource).then(document => { vscode.window.showTextDocument(document, activePreviewResourceColumn); }); </ins> } return undefined; }

const resource = vscode.Uri.parse(state.resource); const locked = state.locked; const line = state.line; <ins> const resourceColumn = state.resourceColumn; </ins> const preview = new MarkdownPreview( webview, resource, locked, <ins> resourceColumn, </ins> contentProvider, previewConfigurations, logger,

public static create( resource: vscode.Uri, previewColumn: vscode.ViewColumn, <ins> resourceColumn: vscode.ViewColumn, </ins> locked: boolean, contentProvider: MarkdownContentProvider, previewConfigurations: MarkdownPreviewConfigurationManager,

webview, resource, locked, <ins> resourceColumn, </ins> contentProvider, previewConfigurations, logger,

webview: vscode.WebviewPanel, resource: vscode.Uri, locked: boolean, <ins> private readonly _resourceColumn: vscode.ViewColumn, </ins> private readonly _contentProvider: MarkdownContentProvider, private readonly _previewConfigurations: MarkdownPreviewConfigurationManager, private readonly _logger: Logger,

return this._resource; } <ins> public get resourceColumn(): vscode.ViewColumn { return this._resourceColumn; } </ins> public get state() { return { resource: this.resource.toString(), locked: this._locked, line: this.line, <ins> resourceColumn: this.resourceColumn, </ins> imageInfo: this.imageInfo }; }

return this._activePreview && this._activePreview.resource; } <ins> public get activePreviewResourceColumn() { return this._activePreview && this._activePreview.resourceColumn; } </ins> public toggleLock() { const preview = this._activePreview; if (preview) {

const preview = MarkdownPreview.create( resource, previewSettings.previewColumn, <ins> previewSettings.resourceColumn, </ins> previewSettings.locked, this._contentProvider, this._previewConfigurations,