From 3abcabd4e8a4929ae9f15cf05ae4e8a7dbaaec11 Mon Sep 17 00:00:00 2001 From: Hans Date: Tue, 14 Dec 2021 08:55:54 +0800 Subject: [PATCH] fix generates different html content for the same markdown (#138935) fix generates different html content for the same markdown when get the cached token --- .../markdown-language-features/src/markdownEngine.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extensions/markdown-language-features/src/markdownEngine.ts b/extensions/markdown-language-features/src/markdownEngine.ts index 29d5274dc41..8460b71dcd8 100644 --- a/extensions/markdown-language-features/src/markdownEngine.ts +++ b/extensions/markdown-language-features/src/markdownEngine.ts @@ -164,6 +164,7 @@ export class MarkdownEngine { ): Token[] { const cached = this._tokenCache.tryGetCached(document, config); if (cached) { + this.resetSlugCount(); return cached; } @@ -173,10 +174,14 @@ export class MarkdownEngine { } private tokenizeString(text: string, engine: MarkdownIt) { - this._slugCount = new Map(); + this.resetSlugCount(); return engine.parse(text.replace(UNICODE_NEWLINE_REGEX, ''), {}); } + + public resetSlugCount(): void { + this._slugCount = new Map(); + } public async render(input: SkinnyTextDocument | string, resourceProvider?: WebviewResourceProvider): Promise { const config = this.getConfig(typeof input === 'string' ? undefined : input.uri);