fix generates different html content for the same markdown (#138935)

fix generates different html content for the same markdown when get the cached token
This commit is contained in:
Hans
2021-12-14 08:55:54 +08:00
committed by GitHub
parent ddaf6a258c
commit 3abcabd4e8

View File

@@ -164,6 +164,7 @@ export class MarkdownEngine {
): Token[] { ): Token[] {
const cached = this._tokenCache.tryGetCached(document, config); const cached = this._tokenCache.tryGetCached(document, config);
if (cached) { if (cached) {
this.resetSlugCount();
return cached; return cached;
} }
@@ -173,10 +174,14 @@ export class MarkdownEngine {
} }
private tokenizeString(text: string, engine: MarkdownIt) { private tokenizeString(text: string, engine: MarkdownIt) {
this._slugCount = new Map<string, number>(); this.resetSlugCount();
return engine.parse(text.replace(UNICODE_NEWLINE_REGEX, ''), {}); return engine.parse(text.replace(UNICODE_NEWLINE_REGEX, ''), {});
} }
public resetSlugCount(): void {
this._slugCount = new Map<string, number>();
}
public async render(input: SkinnyTextDocument | string, resourceProvider?: WebviewResourceProvider): Promise<RenderOutput> { public async render(input: SkinnyTextDocument | string, resourceProvider?: WebviewResourceProvider): Promise<RenderOutput> {
const config = this.getConfig(typeof input === 'string' ? undefined : input.uri); const config = this.getConfig(typeof input === 'string' ? undefined : input.uri);