nvim-treesitter / nvim-treesitter/nvim-treesitter-textobjects

Weird behavior for @block.* in some languages

Open
#797 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Tree-sitter Query
Stars
2.8k
Forks
271
Avg merge
8d 8h
Merged PRs (30d)
1

Description

Describe the bug
The queries for @block.inner and @block.outer are very unituitive and not all that useful to me, at least for rust and ecma script. As an example: this is selected with @block.inner:

Image

So basically the outer block. Instead I would expect something like that to be selected

Image

To Reproduce
Steps to reproduce the behavior:
Use the @block.* text objects

Expected behavior
The content inside the block is selected for @block.inner or the block itself for @block.outer

Output of :checkhealth nvim-treesitter

N/A

Output of nvim --version

N/A

Additional context
I created a PR here that fixes it in rust and ecma script, if this behavior is noticed in other languages as well I can try and add those as well. For lua it works well, so maybe not a general problem

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the proposed fix in PR #796 and compare the @block.inner and @block.outer queries for Rust and ECMAScript with Lua’s working behavior. Check whether other language queries show the same selection problem and verify the expected inner and outer selections before extending the fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.