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

textobject_at_point can generates matches without nodes

Open
#442 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

E5108: Error executing lua: ...r-textobjects/lua/nvim-treesitter/textobjects/shared.lua:269: attempt to index field
 'node' (a nil value)
stack traceback:
│       ...r-textobjects/lua/nvim-treesitter/textobjects/shared.lua:269: in function 'textobject_at_point'

To Reproduce
Steps to reproduce the behavior:

  1. Open buffer with something line (print 1 2 3), ft=fennel
  2. :lua require'nvim-treesitter.textobjects.shared'.textobject_at_point("@call")
  3. See error

Expected behavior
Probably some warning about what's wrong with the invocation. @call is a query that exists for fennel in this repo.

Inspecting the matches table, I see an inner and outer, both with nodes, but my query did not specify. I think this call should error out if the query doesn't specify .inner or .outer.

Output of nvim --version

nvim --version
NVIM v0.9.0
Build type: Release
LuaJIT 2.1.0-beta3

Additional context
Add any other context about the problem here.

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 in lua/nvim-treesitter/textobjects/shared.lua at line 269 and reproduce the issue with textobject_at_point("@call") on a Fennel buffer containing (print 1 2 3). Inspect how matches without an inner or outer node are handled; done means the invocation no longer indexes a nil node and reports the missing query selection clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.