дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 10:07:11 +02:00
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 <[email protected]>
Цей коміт міститься в:
1 джерело
de325c4d3c
коміт
7164e17f1c
1 file changed
+3
-1
@@ -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!);
|
||||
|
||||
Reference in new issue
Заблокувати користувача