Fix syntax highlighting for files ending in a newline.
Review Request #15229 — Created Aug. 14, 2026 and updated — Latest diff uploaded
Nodes that consume a file's trailing newline (such as markdown headings
and metadata blocks) end at the start of a row past the last line.
_get_nodes_by_line()indexedlines[end_row]unguarded and crashed
with anIndexError, which the chunk generator masked by silently
falling back to Pygments, so affected files never got tree-sitter
highlighting.This change clamps such nodes to the end of the last line, and skips
nodes that start past it entirely (error-recovery nodes can have odd
extents).
- Added unit tests for both clamping cases, and an end-to-end test for a
newline-terminated markdown file with a YAML frontmatter injection. - Ran unit tests.