提交 eb29e868 编写于 作者: M Matt Bierner

Use uri

上级 ef028455
...@@ -46,24 +46,22 @@ export class OpenDocumentLinkCommand implements Command { ...@@ -46,24 +46,22 @@ export class OpenDocumentLinkCommand implements Command {
public async execute(args: OpenDocumentLinkArgs) { public async execute(args: OpenDocumentLinkArgs) {
const fromResource = vscode.Uri.parse(decodeURIComponent(args.fromResource)); const fromResource = vscode.Uri.parse(decodeURIComponent(args.fromResource));
const targetPath = decodeURIComponent(args.path); const targetPath = decodeURIComponent(args.path);
const targetResource = vscode.Uri.file(targetPath);
const column = this.getViewColumn(fromResource); const column = this.getViewColumn(fromResource);
try { try {
return await this.tryOpen(targetPath, args, column); return await this.tryOpen(targetResource, args, column);
} catch { } catch {
if (targetPath && extname(targetPath) === '') { if (extname(targetResource.path) === '') {
return this.tryOpen(targetPath + '.md', args, column); 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); await vscode.commands.executeCommand('vscode.open', targetResource, column);
return undefined; return undefined;
} }
} }
private async tryOpen(path: string, args: OpenDocumentLinkArgs, column: vscode.ViewColumn) { private async tryOpen(resource: vscode.Uri, args: OpenDocumentLinkArgs, column: vscode.ViewColumn) {
const resource = vscode.Uri.file(path);
if (vscode.window.activeTextEditor && isMarkdownFile(vscode.window.activeTextEditor.document)) { 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); return this.tryRevealLine(vscode.window.activeTextEditor, args.fragment);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册