nvim-treesitter / nvim-treesitter-textobjects

Apache License 2.0
2.14k stars 191 forks source link

`swap` can not swap children across parents #677

Open ofseed opened 1 month ago

ofseed commented 1 month ago

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.