Skip to content

fix(textobject): fall back to parent layers for tree-sitter textobjects - #16367

Open
beeb wants to merge 1 commit into
helix-editor:masterfrom
beeb:fix/textobject-injection-fallback
Open

beeb wants to merge 1 commit into
helix-editor:masterfrom
beeb:fix/textobject-injection-fallback

Conversation

@beeb

@beeb beeb commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Closes #16366.

Since d27856b, textobject_treesitter only looks at the innermost injection layer under the cursor.
If that layer's language has no textobject query, or no matching capture, the selection does not change. It should fall back to the enclosing language.

The most visible case is comments: in Rust (and any language that injects comment), mic and mac do nothing when the cursor is inside a comment, because the comment language has no textobjects.scm.
Doc comments are affected the same way through the markdown-rustdoc injection.

The fix iterates through the layers at the cursor from inside to outside and uses the first one that gives a node containing the cursor.

Added a regression test that selects comment.inside with the cursor inside a Rust line comment.

Related: #16335 fixes the same problem for goto_treesitter_object (]c / [c, see #16333). The fixes are independent, though.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Match inside comment does not work [Rust]

1 participant