tree-sitter-nu icon indicating copy to clipboard operation
tree-sitter-nu copied to clipboard

queries can't match the last pipe_element in a pipeline

Open Bahex opened this issue 5 months ago • 2 comments

I’m not sure if this is a bug in our parser or in tree-sitter.

nushell source

tree-sitter query

  1
| 2
| 3
(pipeline . (pipe_element)  @first   )
(pipeline   (pipe_element)  @last_ . )

With the tree-sitter cli:

> tree-sitter query -c query.scm source.nu
source.nu
    pattern:  0, capture: 0 - first, start: (0, 2), end: (0, 3), text: `1`
    pattern:  1, capture: 1 - last_, start: (0, 2), end: (0, 3), text: `1`
    pattern:  1, capture: 1 - last_, start: (1, 2), end: (1, 3), text: `2`
    pattern:  1, capture: 1 - last_, start: (2, 2), end: (2, 3), text: `3`

Within neovim:

First Last

Bahex avatar Jul 08 '25 14:07 Bahex

I have filed an issue.

Appears to be a tree-sitter bug that happens to be triggered by our "crazy" grammar.

It's really weird in my opinion, query matching is supposed to be based purely on the parsing results, and parser agnostic. Yet it does behave inconsistently between nushell and others.

blindFS avatar Jul 08 '25 14:07 blindFS

The bug was initially introduced by #139 . Maybe it has something to do with newline characters.

blindFS avatar Jul 08 '25 14:07 blindFS