Skip to content

Incremental line highlighter for editors (0.2.0) - #18

Merged
arpan404 merged 11 commits into
mainfrom
ace/line-highlighter
Nov 18, 2026
Merged

arpan404 merged 11 commits into
mainfrom
ace/line-highlighter

Conversation

@arpan404

Copy link
Copy Markdown
Owner

Adds LineHighlighter, an incremental highlighter for code editors that call markit on every keystroke, and releases it as 0.2.0.

  • LineHighlighter::new(language), set_text, edit(start_line, removed_lines, inserted), tokens(start_line, end_line): an edit invalidates parse state from its first line only, and re-parsing stops where the parser state matches the cached one. Tokens and colours are identical to highlight for the same text (tested on every fixture and on seeded edits).
  • A parse budget per tokens call (default 2,000 lines) with advance(max_lines) for idle catch-up, so opening deep in a large file returns at once with plain tokens.
  • Parser state is kept at checkpoints every 32 lines and token runs in a bounded 2,000-line cache: 26 B/line of cache for a 200,000-line file (was 672 B/line). Lines over 2,048 bytes stay plain, as in highlight.
  • Exposed through markit-wasm (LineHighlighter class), the C FFI (markit_line_highlighter_*, handles may move between threads one at a time) and Kotlin (Markit.LineHighlighter, process-wide registry with a cleaner).
  • Line model: lines split on \n only, \r\n is a line ending, a lone \r is content, a trailing newline makes a final empty line.
  • scripts/release.sh also ships markit-android-<version>.zip when an Android NDK is present.

Bench, 200,000-line Rust file: one edit plus a 60-line viewport, p50 about 5.5 ms.

arpan404 and others added 11 commits November 17, 2026 16:36
Co-Authored-By: spade <bot@acehq.dev>
Co-Authored-By: spade <bot@acehq.dev>
Co-Authored-By: spade <bot@acehq.dev>
Co-Authored-By: spade <bot@acehq.dev>
Co-Authored-By: spade <bot@acehq.dev>
Co-Authored-By: spade <bot@acehq.dev>
Co-Authored-By: spade <bot@acehq.dev>
Co-Authored-By: spade <bot@acehq.dev>
Co-Authored-By: spade <bot@acehq.dev>
Co-Authored-By: spade <bot@acehq.dev>
@arpan404
arpan404 merged commit c7d6c84 into main Nov 18, 2026
10 checks passed
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.

1 participant