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

fix: inline anonymous nodes

Open clason opened this issue 1 year ago • 2 comments

Problem: The "trick" of wrapping an anonymous node into a single choice or seq no longer works as of https://github.com/tree-sitter/tree-sitter/pull/2577 since the wrapped anonymous nodes are no longer exposed to queries. This means generating with tree-sitter > 0.22.6 leads to a broken parser.

Solution: Inline anonymous nodes.

@amaanq

clason avatar Jul 07 '24 13:07 clason

ping @maaslalani

clason avatar Jul 08 '24 09:07 clason

ping @caarlos0

If this project is no longer officially maintained, consider archiving it so we can drop it from nvim-treesitter.

clason avatar Jul 23 '24 11:07 clason

hey, sorry for the delay reviewing this

caarlos0 avatar Aug 17 '24 18:08 caarlos0

@clason @caarlos0

~Not sure if I'm maybe missing something~, but following this merge a number of tests now fail, specifically:

  • examples: Glow
  • all: Display
  • all: Copy Paste

node.js 20.16.0 LTS

  1. git clone [email protected]:charmbracelet/tree-sitter-vhs.git && cd tree-sitter-vhs
  2. npm install
  3. npm run generate
  4. npm test

EDIT:

It seems to be because tree-sitter-cli in package-lock.json is pinned to 0.20.8 with version specified in devDependencies at 0.20.7. Upgrading to 0.22.6 fixes the issue.

nixpig avatar Aug 21 '24 03:08 nixpig

ah, cool, thanks for investigating!

wanna PR it @nixpig ?

caarlos0 avatar Aug 21 '24 18:08 caarlos0

Not sure how I reached the conclusion that simply upgrading tree-sitter-cli fixed the broken tests. Looking at it again this morning, it seems the change in output is correct, i.e. what was previously (command (node)) is now simply (command).

If @clason can confirm, then I'm happy to submit a PR with updates to tests and upgrade to latest tree-sitter-cli.

nixpig avatar Aug 22 '24 03:08 nixpig

Can you point me to these failing tests? The grammar change should not have affected any queries, and in particular should not make such a huge, sweeping, difference as the one you state.

And the first thing anybody should do is set up some workflows to run tests on PRs ;) (You can use https://github.com/tree-sitter-grammars/template as a base.)

clason avatar Aug 22 '24 07:08 clason

  1. npm install
  2. npm run generate
  3. npm test

Any tests using Hide, Show, Copy and Paste fail. For example, the Glow tests in test/corpus/examples.txt, the Display and Copy Paste tests in test/corpus/all.txt.

image image image

nixpig avatar Aug 23 '24 03:08 nixpig

Yes, those tests need to be adapted since the corresponding nodes are now visible. Just do tree-sitter test -u, or edit the expected output manually.

clason avatar Aug 23 '24 06:08 clason