From 3afaa9d9f18465a4641175c17a6439c31b88f7f3 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 10 Nov 2017 16:43:21 -0800 Subject: [PATCH] Support for wiki links in the markdown editor Fixes #37400 --- extensions/markdown/src/extension.ts | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/extensions/markdown/src/extension.ts b/extensions/markdown/src/extension.ts index c34f12e44b8..aa3c9f71918 100644 --- a/extensions/markdown/src/extension.ts +++ b/extensions/markdown/src/extension.ts @@ -157,14 +157,25 @@ export function activate(context: vscode.ExtensionContext) { } } }; - if (vscode.window.activeTextEditor && isMarkdownFile(vscode.window.activeTextEditor.document) && vscode.window.activeTextEditor.document.uri.fsPath === args.path) { - return tryRevealLine(vscode.window.activeTextEditor); - } else { + + const tryOpen = async (path: string) => { + if (vscode.window.activeTextEditor && isMarkdownFile(vscode.window.activeTextEditor.document) && vscode.window.activeTextEditor.document.uri.fsPath === path) { + return tryRevealLine(vscode.window.activeTextEditor); + } else { + const resource = vscode.Uri.file(path); + return vscode.workspace.openTextDocument(resource) + .then(vscode.window.showTextDocument) + .then(tryRevealLine); + } + }; + + return tryOpen(args.path).catch(() => { + if (path.extname(args.path) === '') { + return tryOpen(args.path + '.md'); + } const resource = vscode.Uri.file(args.path); - return vscode.workspace.openTextDocument(resource) - .then(vscode.window.showTextDocument) - .then(tryRevealLine, _ => vscode.commands.executeCommand('vscode.open', resource)); - } + return vscode.commands.executeCommand('vscode.open', resource); + }); })); context.subscriptions.push(vscode.commands.registerCommand('markdown.showPreviewSecuritySelector', (resource: string | undefined) => { -- GitLab