mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
make vscode.d.ts-link detector fit for multi root
This commit is contained in:
parent
9dbadf2347
commit
8bba4098c7
|
@ -22,14 +22,14 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
|
||||
const _linkProvider = new class implements vscode.DocumentLinkProvider {
|
||||
|
||||
private _cachedResult: { version: number; links: vscode.DocumentLink[] };
|
||||
private _cachedResult: { key: string; links: vscode.DocumentLink[] };
|
||||
private _linkPattern = /[^!]\[.*?\]\(#(.*?)\)/g;
|
||||
|
||||
provideDocumentLinks(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.DocumentLink[] {
|
||||
const { version } = document;
|
||||
if (!this._cachedResult || this._cachedResult.version !== version) {
|
||||
const key = `${document.uri.toString()}@${document.version}`;
|
||||
if (!this._cachedResult || this._cachedResult.key !== key) {
|
||||
const links = this._computeDocumentLinks(document);
|
||||
this._cachedResult = { version, links };
|
||||
this._cachedResult = { key, links };
|
||||
}
|
||||
return this._cachedResult.links;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue