• 
      

    Fix syntax highlighting for files ending in a newline.

    Review Request #15229 — Created Aug. 14, 2026 and updated

    Information

    Review Board
    release-9.x

    Reviewers

    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() indexed lines[end_row] unguarded and crashed
    with an IndexError, 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.
    Summary ID
    Fix syntax highlighting for files ending in a newline.
    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() indexed lines[end_row] unguarded and crashed with an IndexError, 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). Testing Done: - 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 (reviewboard/treesitter).
    xmoorvvllqltskpmwtrywvzxmylrqpyk
    Checks run (2 succeeded)
    flake8 passed.
    JSHint passed.
    chipx86
    1. Ship It!
    2.