helix icon indicating copy to clipboard operation
helix copied to clipboard

feat(command): select all siblings and children

Open dead10ck opened this issue 1 year ago • 5 comments

This adds two new related commands:

select_all_siblings

Selects all siblings of the node under the cursor.

asciicast

select_all_children

Selects all children of the node under the cursor.

asciicast

select_all_children_in_selection

Selects all children of the node under the cursor, but only if the children are contained inside the starting selection.

dead10ck avatar Jun 25 '23 04:06 dead10ck

after trying this out for a bit I think select_all_children would benefit a lot from only selecting children that are actually contained in the selection. The current implementation is also useful but i found that quite a lof of nodes have children I don't care about. If someone really wants all children inside the node they can do a-o first. That change would also make the command more predictable I think

pascalkuthe avatar Jun 25 '23 11:06 pascalkuthe

after trying this out for a bit I think select_all_children would benefit a lot from only selecting children that are actually contained in the selection.

Hmm, but in this case, the command would basically never do anything when the selection is just a cursor, or really any time you don't happen to have an entire node contained in the selection.

But on the other hand, I could see this being useful for if you only want a subset of the children. I'll add a third command that does this.

dead10ck avatar Jun 25 '23 13:06 dead10ck

Just added select_all_children_in_selection that only selects if all resulting ranges are contained within the starting selection.

dead10ck avatar Jun 25 '23 17:06 dead10ck

Sounds good, will do

dead10ck avatar Apr 07 '24 16:04 dead10ck

Ok I've rebased and changed all the motions to use the new in-crate TreeCursor instead of the tree-sitter API directly. This required adding a child iterator in the TreeCursor module.

dead10ck avatar Apr 07 '24 20:04 dead10ck

Good suggestions, I took care of them.

dead10ck avatar Apr 08 '24 15:04 dead10ck

I can finally stop splitting by commas inside a function call to select the arguments :) But it seems the docs weren't updated with the new alt-a and alt-I keybinds.

sudormrfbin avatar Apr 14 '24 07:04 sudormrfbin