mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 08:38:56 +01:00
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:
@@ -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,11 +174,15 @@ 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);
|
||||||
const engine = await this.getEngine(config);
|
const engine = await this.getEngine(config);
|
||||||
|
|||||||
Reference in New Issue
Block a user