Skip to content

text-color: linear edge checks (a long quote run with a colour span froze rendering) - #106

Open
JSKitty wants to merge 1 commit into
masterfrom
fix/text-color-linear
Open

JSKitty wants to merge 1 commit into
masterfrom
fix/text-color-linear

Conversation

@JSKitty

@JSKitty JSKitty commented Nov 19, 2026

Copy link
Copy Markdown

What

tcMarkSpans walks a colour span's edge past syntax characters one step at a time, and each step rescanned back to the start of the line (lastIndexOf('\n'), the > quote-prefix and open-tag regexes, and ) looking back for ](). On a long line that is quadratic. A message made of > repeated, carrying one colour span, took 1.7 s at 40 KB and 7.1 s at 80 KB in Node, and it does this on every render.

This builds per-position look-back tables once per call: last newline, last ](, last < and >, and where each run of quote marks starts. Each check is then O(1). lastIndexOf('\n', -1) still checks index 0, as before.

Verification

  • Old against new JS on 42,000 random cases (four sets, including 20,000 heavy on <, >, ](, ) and newlines), with spans: 0 differences.
  • 80 KB of > with a span: 7.1 s → 87 ms.
  • npm run check:globals: clean.

The GPUI port carries the same fix (crates/vector-gpui/src/textcolor.rs on gpui), checked against this JS with the same harness.


Generated by Claude Code

Walking an edge along a long line rescanned back to its start at every
step, so a long run of quote marks with a colour span took seconds to
render. Same output, linear.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qq6RetJnzXvEeXAvSsgvs1
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

JSKitty commented Nov 19, 2026

Copy link
Copy Markdown
Author

The failing claude check is the claude-code-action review job, not a build or test. It ran with no ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN, so it stopped at its environment check before reviewing anything; it failed the same way on #105. This diff only touches src/js/text-color.js. The src-tauri, vector-core and CodeQL checks are green.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants