fix(language-server): bypass cache for version-less documents
This commit is contained in:
@@ -100,12 +100,16 @@ export function isInsideHtml(document: TextDocument, offset: number): boolean {
|
||||
const regionCache = new Map<string, { version: number; regions: HtmlRegion[] }>();
|
||||
|
||||
function regionsFor(document: TextDocument): HtmlRegion[] {
|
||||
const version = document.version ?? -1;
|
||||
// Documents without a version have no way to signal changes, so bypass cache.
|
||||
if (document.version === undefined) {
|
||||
return viewRegions(document.text);
|
||||
}
|
||||
|
||||
const cached = regionCache.get(document.uri);
|
||||
if (cached && cached.version === version) return cached.regions;
|
||||
if (cached && cached.version === document.version) return cached.regions;
|
||||
|
||||
const regions = viewRegions(document.text);
|
||||
regionCache.set(document.uri, { version, regions });
|
||||
regionCache.set(document.uri, { version: document.version, regions });
|
||||
return regions;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user