Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion extensions/markdown-language-features/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export async function startClient(factory: LanguageClientConstructor, workspace:
return looksLikeMarkdownPath(resource);
},
},

};

const client = factory('markdown', localize('markdownServer.name', 'Markdown Language Server'), clientOptions);
Expand Down Expand Up @@ -116,6 +115,10 @@ export async function startClient(factory: LanguageClientConstructor, workspace:
watchers.delete(params.id);
});

vscode.commands.registerCommand('vscodeMarkdownLanguageservice.open', (uri, args) => {
return vscode.commands.executeCommand('vscode.open', uri, args);
});

await client.start();

return client;
Expand Down
19 changes: 18 additions & 1 deletion extensions/markdown-language-features/src/util/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import * as vscode from 'vscode';
import * as URI from 'vscode-uri';
import { Schemes } from './schemes';

export const markdownFileExtensions = Object.freeze<string[]>([
'md',
Expand All @@ -22,6 +23,22 @@ export function isMarkdownFile(document: vscode.TextDocument) {
return document.languageId === 'markdown';
}

export function looksLikeMarkdownPath(resolvedHrefPath: vscode.Uri) {
export function looksLikeMarkdownPath(resolvedHrefPath: vscode.Uri): boolean {
const doc = vscode.workspace.textDocuments.find(doc => doc.uri.toString() === resolvedHrefPath.toString());
if (doc) {
return isMarkdownFile(doc);
}

if (resolvedHrefPath.scheme === Schemes.notebookCell) {
for (const notebook of vscode.workspace.notebookDocuments) {
for (const cell of notebook.getCells()) {
if (cell.kind === vscode.NotebookCellKind.Markup && isMarkdownFile(cell.document)) {
return true;
}
}
}
return false;
}

return markdownFileExtensions.includes(URI.Utils.extname(resolvedHrefPath).toLowerCase().replace('.', ''));
}