Code Editor โ
Problem โ
Every keystroke must update highlighting, folding, and diagnostics in milliseconds on large files.
Why tree-sitter.zig helps โ
One long-lived Parser plus per-keystroke InputEdits keeps reparse work proportional to the edit. Reuse counters (reused_node_count) let you verify the budget in production.
API โ
Parser (reused), InputEdit, Tree, getChangedRanges, TreeCursor.
Architecture โ
text
Buffer โ keystroke โ InputEdit โ parse(old, edit, text)
โ changed ranges โ update faces/folds/diagnosticsExample โ
See Incremental: 1 + 2 โ 1 + 22 reparses with a one-span diff.
Output โ
text
changed: bytes [4, 6]