mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
Support latest md ls (#160228)
- Update `looksLikeMarkdownPath` to look at open documents and notebooks, not just the uri - Register custom command for document links
This commit is contained in:
parent
c8dd96f73b
commit
077f5865da
|
@ -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);
|
||||
|
@ -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;
|
||||
|
|
|
@ -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',
|
||||
|
@ -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('.', ''));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue