mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 19:44:25 +01:00
Fix Markdown TOC Provider for Invalid References (#22553)
Fixes #22494 **Bug** References without a definition can cause the markdown table of contents provider to break **Fix** Pass in an empty environment to markdown-it `parse` to prevent the null dereference on invalid links.
This commit is contained in:
@@ -17,7 +17,7 @@ export interface IToken {
|
||||
interface MarkdownIt {
|
||||
render(text: string): string;
|
||||
|
||||
parse(text: string): IToken[];
|
||||
parse(text: string, env: any): IToken[];
|
||||
|
||||
utils: any;
|
||||
}
|
||||
@@ -83,9 +83,10 @@ export class MarkdownEngine {
|
||||
return this.engine.render(text);
|
||||
}
|
||||
|
||||
public parse(source: string): IToken[] {
|
||||
public parse(document: vscode.Uri, source: string): IToken[] {
|
||||
const {text, offset} = this.stripFrontmatter(source);
|
||||
return this.engine.parse(text).map(token => {
|
||||
this.currentDocument = document;
|
||||
return this.engine.parse(text, {}).map(token => {
|
||||
if (token.map) {
|
||||
token.map[0] += offset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user