• 
      

    Tree Sitter: Implement the offset! and make-range! query directives.

    Review Request #15217 — Created Aug. 5, 2026 and submitted

    Information

    Review Board
    release-9.x

    Reviewers

    Our predicate handler rejected any query match using a predicate or
    directive it did not implement. nvim-treesitter's queries use the
    nvim-only #offset! and #make-range! directives, so every pattern
    containing one silently never matched. This change implements both.

    offset! stores its range deltas in the query's pattern settings,
    matching nvim's semantics of adding each delta to the corresponding
    (row, column) range component. Injection handling in highlight.py now
    applies those deltas when building injected-language ranges, recomputing
    byte offsets from the adjusted points. This fixes injection patterns
    that were previously rejected outright in the vendored injections.scm
    files of ~19 languages, such as markdown's YAML frontmatter injection
    and quote-trimming injections for template strings.

    make-range! defines a named range spanning two captures. Nothing in
    Review Board consumes those synthetic ranges, so the handler just stops
    the match from being rejected.

    This also allows the upcoming interesting_lines.scm queries for fennel,
    fish, and zig to keep their directives instead of having them stripped
    at vendor time.

    • Added unit tests for the directive handlers and for the range
      adjustment math.
    • Added an end-to-end test verifying that markdown YAML frontmatter is
      highlighted as YAML, with the fence lines excluded from the injected
      region.
    • Ran unit tests.
    Summary ID
    Tree Sitter: Implement the offset! and make-range! query directives.
    Our predicate handler rejected any query match using a predicate or directive it did not implement. nvim-treesitter's queries use the nvim-only `#offset!` and `#make-range!` directives, so every pattern containing one silently never matched. This change implements both. `offset!` stores its range deltas in the query's pattern settings, matching nvim's semantics of adding each delta to the corresponding (row, column) range component. Injection handling in highlight.py now applies those deltas when building injected-language ranges, recomputing byte offsets from the adjusted points. This fixes injection patterns that were previously rejected outright in the vendored injections.scm files of ~19 languages, such as markdown's YAML frontmatter injection and quote-trimming injections for template strings. `make-range!` defines a named range spanning two captures. Nothing in Review Board consumes those synthetic ranges, so the handler just stops the match from being rejected. This also allows the upcoming interesting_lines.scm queries for fennel, fish, and zig to keep their directives instead of having them stripped at vendor time. Testing Done: - Added unit tests for the directive handlers and for the range adjustment math. - Added an end-to-end test verifying that markdown YAML frontmatter is highlighted as YAML, with the fence lines excluded from the injected region. - Ran unit tests.
    rmowuunrmpskwrpkxvwwxvymnrqqpknl
    Description From Last Updated

    Can you wrap True in double backticks.

    maubin maubin

    Can you wrap True in double backticks.

    maubin maubin
    maubin
    1. 
        
    2. reviewboard/treesitter/predicates.py (Diff revision 1)
       
       
      Show all issues

      Can you wrap True in double backticks.

    3. reviewboard/treesitter/predicates.py (Diff revision 1)
       
       
      Show all issues

      Can you wrap True in double backticks.

    4. 
        
    david
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-9.x (f51353f)