From 7164e17f1cdabaa3677fc9f082987541dfd825d3 Mon Sep 17 00:00:00 2001 From: faysou Date: Tue, 24 Nov 2026 13:00:19 +0000 Subject: [PATCH] test(editor): prepare the syntax tree before measuring line highlights (#5627) On a busy runner CodeMirror could exhaust its foreground parse budget before reaching the test string, so the line-literal test failed before measuring. The test now prepares the tree through the target line first. Co-authored-by: faysou <893862+faysou@users.noreply.github.com> --- src/editor/core/cm/literals.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/editor/core/cm/literals.test.ts b/src/editor/core/cm/literals.test.ts index 4a0d9aaa94..c9b3ae30d4 100644 --- a/src/editor/core/cm/literals.test.ts +++ b/src/editor/core/cm/literals.test.ts @@ -1,6 +1,6 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import { EditorState } from "@codemirror/state"; -import { StreamLanguage } from "@codemirror/language"; +import { ensureSyntaxTree, StreamLanguage } from "@codemirror/language"; import { javascript } from "@codemirror/lang-javascript"; import { kotlin } from "@codemirror/legacy-modes/mode/clike"; import { highlightTree } from "@lezer/highlight"; @@ -60,6 +60,8 @@ describe("lineLiteralAt", () => { const state = EditorState.create({ doc: code(lines), extensions: typescript() }); const pos = state.doc.toString().indexOf('"value 150"') + 3; const line = state.doc.lineAt(pos); + // This measures highlighting work after the parser has reached the caret. + expect(ensureSyntaxTree(state, line.to + 1, Infinity)).not.toBeNull(); highlighted.mockClear(); expect(lineLiteralAt(state, pos)?.kind).toBe("string"); const covered = windows().map(([from, to]) => to! - from!);