mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-22 16:10:50 +00:00
* improve terminal keyword highlight refresh * fix(terminal): address Codex review on keyword highlight refresh Map viewport probe diffs to line numbers so off-cursor ANSI redraws mark the rewritten line dirty without forcing full-viewport rescans on normal typing, and cache wrapped-line context per processLineRange to avoid repeated scans. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: mam15mon <mam15mon@gmail.com> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1019 B
TypeScript
39 lines
1019 B
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { forEachNonEmptyRegexMatch } from "./keywordHighlightRegex.ts";
|
|
|
|
test("forEachNonEmptyRegexMatch returns normal consuming matches", () => {
|
|
const regex = /\bfoo\b/gi;
|
|
const indices: number[] = [];
|
|
|
|
forEachNonEmptyRegexMatch(regex, "foo bar foo", (match) => {
|
|
indices.push(match.index);
|
|
});
|
|
|
|
assert.deepEqual(indices, [0, 8]);
|
|
});
|
|
|
|
test("forEachNonEmptyRegexMatch skips zero-width matches without looping forever", () => {
|
|
const regex = /(?=foo)/g;
|
|
const indices: number[] = [];
|
|
|
|
forEachNonEmptyRegexMatch(regex, "foo foo", (match) => {
|
|
indices.push(match.index);
|
|
});
|
|
|
|
assert.deepEqual(indices, []);
|
|
});
|
|
|
|
test("forEachNonEmptyRegexMatch resets reused regex state before scanning", () => {
|
|
const regex = /\d+/g;
|
|
const indices: number[] = [];
|
|
|
|
regex.lastIndex = 99;
|
|
forEachNonEmptyRegexMatch(regex, "1 22 333", (match) => {
|
|
indices.push(match.index);
|
|
});
|
|
|
|
assert.deepEqual(indices, [0, 2, 5]);
|
|
});
|