nvim-treesitter / nvim-treesitter/nvim-treesitter-textobjects
`swap` can not swap children across parents
Nobody has claimed this yet.
- Dominant language
- Tree-sitter Query
- Stars
- 2.8k
- Forks
- 271
- Avg merge
- 8d 8h
- Merged PRs (30d)
- 1
Description
To record a regression I found while refactoring main.
function f1(arg1, arg2)
...
end
function f2(arg3, arg4)
...
end
Formerly if we call swap_next("@parameter.inner") while the cursor is at arg2, nothing will happen, because there's no next parameter in the same parent node. Now it will swap with arg3 in f2 because it is the next parameter even though they do not have a common parent node.
Currently, it seems not possible to do this because we only record nodes' range, but it should be easily fixed if we complete https://github.com/nvim-treesitter/nvim-treesitter-textobjects/pull/674.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the example by calling swap_next("@parameter.inner") at arg2, then read PR #674 and the swap_next entry point to understand the recorded node ranges. Done means parameters are swapped only when they share a parent, so arg2 is not exchanged with arg3 in f2.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, neovim
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100