-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tree-sitter movements do not respect extend mode #1999
Comments
I would add |
Extending with shift is kakoune-like and would be inconsistent with the rest of the selection extending commands. This should work with selection mode |
Implementation-wise, here are the commands for moving the selection to siblings. Instead of naively replacing the selection, we need to union the selection between the existing selection and the new node when in selection mode. I think extending makes sense for select_next_sibling and select_prev_sibling but not for expand_selection ( |
I think But trying to think about these commands as navigation raises the question, "should tree-sitter movements in select mode
|
Oh hmm that's a good question. Originally I was thinking the union, so if you had something like myfunc(a, [b], c) # selection is around `b` with a tree like (call
(argument)
(argument) ; selection is wrapping this
(argument))
myfunc(a, [b], [c]) # one selection for `b`, another for `c` (call
(argument)
(argument) ; one here
(argument)) ; another here But it might be useful to have it extend the range of the current selection, so: myfunc(a, [b, c]) # selection starting at `b`, ending on `c` I suppose I would lean towards the union that makes new selections which is similar to how |
Union: put_cursor should be enough for extending downwards with the extend flag, it'll move the head but retain the anchor. For extending upwards, construct a new range for the sibling then use put_cursor on it with the current head value? |
@the-mikedavis To me, it seems like both 2 and 3 would be useful in different situations, while 1 could be emulated using 2 with a cursor / anchor swap. The inconsistency of This mode would allow you to "freeze" all non-primary selections while you manipulate the primary selection or add a new selection (which would be useful anyway in a multiple-selection-based editing model). In one possible implementation of this, behavior 3 could be executed as
This allows for more granular control, allowing us, for example, to skip siblings (like operators in an expression), or make selections for more complex non-sibling relationships. The current behavior of This would be a pretty big change to Helix's editing model, and there are some problems to consider.
|
For what is worth I really like the idea of this creating a new selection rather than extending, as @the-mikedavis describes. I'm thinking back to kakoune and the ability to merge selection marks and how something like that might allow us to get the both of best worlds -- |
Summary
The behavior of
<alt>+left
<alt>+right
<alt>+up
<alt>+down
in select/extend mode is the exact same as in normal mode.I expected these commands to extend my selection in select mode, by remembering my original starting point.
Reproduction Steps
I tried this:
(In a supported language)
<alt>+up
and select a syntax nodev
<alt>+right
I expected my selection to be extended to the next tree-sitter node.
Instead, Helix forgets my selection and selects the next tree-sitter node.
Helix log
No response
Platform
Linux
Terminal Emulator
GNOME Console
Helix Version
22.03-49-gb03421a8
The text was updated successfully, but these errors were encountered: