fix(language-server): bypass cache for version-less documents
This commit is contained in:
@@ -107,3 +107,19 @@ test("isInsideHtml distinguishes markup from surrounding code", () => {
|
||||
expect(isInsideHtml(source, markupOffset)).toBe(true);
|
||||
expect(isInsideHtml(source, keywordOffset)).toBe(false);
|
||||
});
|
||||
|
||||
test("documents without a version field scan every time and detect mutations", () => {
|
||||
// Without a version, the cache has no key to validate freshness. Mutations
|
||||
// must be detected on every call, even when uri and document are reused.
|
||||
const source = doc(PAGE);
|
||||
// Explicitly verify version is undefined (not set by doc() helper).
|
||||
expect(source.version).toBeUndefined();
|
||||
|
||||
const markupOffset = PAGE.indexOf("<div");
|
||||
expect(isInsideHtml(source, markupOffset)).toBe(true);
|
||||
|
||||
// Mutate the text: remove the view block.
|
||||
source.text = "page A { }";
|
||||
// Same uri, same missing version, but different text: mutation must be detected.
|
||||
expect(isInsideHtml(source, markupOffset)).toBe(false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user