Prefer reusing open tabs when opening md links in editors (#178628)

Fixes #81238
This commit is contained in:
Matt Bierner 2023-03-29 15:21:31 -07:00 committed by GitHub
parent af5ef24b52
commit 7a463ec271
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,6 +37,18 @@ export class MdLinkOpener {
return vscode.commands.executeCommand('revealInExplorer', uri);
case 'file': {
// If no explicit viewColumn is given, check if the editor is already open in a tab
if (typeof viewColumn === 'undefined') {
for (const tab of vscode.window.tabGroups.all.flatMap(x => x.tabs)) {
if (tab.input instanceof vscode.TabInputText) {
if (tab.input.uri.fsPath === uri.fsPath) {
viewColumn = tab.group.viewColumn;
break;
}
}
}
}
return vscode.commands.executeCommand('vscode.open', uri, <vscode.TextDocumentShowOptions>{
selection: resolved.position ? new vscode.Range(resolved.position.line, resolved.position.character, resolved.position.line, resolved.position.character) : undefined,
viewColumn: viewColumn ?? getViewColumn(fromResource),