From eb29e868de28699714165b9c0212ac7a9f54e411 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 9 Jul 2020 15:35:27 -0700 Subject: [PATCH] Use uri --- .../src/commands/openDocumentLink.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/extensions/markdown-language-features/src/commands/openDocumentLink.ts b/extensions/markdown-language-features/src/commands/openDocumentLink.ts index 28c87f54025..d394368095f 100644 --- a/extensions/markdown-language-features/src/commands/openDocumentLink.ts +++ b/extensions/markdown-language-features/src/commands/openDocumentLink.ts @@ -46,24 +46,22 @@ export class OpenDocumentLinkCommand implements Command { public async execute(args: OpenDocumentLinkArgs) { const fromResource = vscode.Uri.parse(decodeURIComponent(args.fromResource)); const targetPath = decodeURIComponent(args.path); + const targetResource = vscode.Uri.file(targetPath); const column = this.getViewColumn(fromResource); try { - return await this.tryOpen(targetPath, args, column); + return await this.tryOpen(targetResource, args, column); } catch { - if (targetPath && extname(targetPath) === '') { - return this.tryOpen(targetPath + '.md', args, column); + if (extname(targetResource.path) === '') { + return this.tryOpen(targetResource.with({ path: targetResource.path + '.md' }), args, column); } - const targetResource = vscode.Uri.file(targetPath); - await Promise.resolve(undefined); await vscode.commands.executeCommand('vscode.open', targetResource, column); return undefined; } } - private async tryOpen(path: string, args: OpenDocumentLinkArgs, column: vscode.ViewColumn) { - const resource = vscode.Uri.file(path); + private async tryOpen(resource: vscode.Uri, args: OpenDocumentLinkArgs, column: vscode.ViewColumn) { if (vscode.window.activeTextEditor && isMarkdownFile(vscode.window.activeTextEditor.document)) { - if (!path || vscode.window.activeTextEditor.document.uri.fsPath === resource.fsPath) { + if (vscode.window.activeTextEditor.document.uri.fsPath === resource.fsPath) { return this.tryRevealLine(vscode.window.activeTextEditor, args.fragment); } } -- GitLab