-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Inserting line breaks collapses selections #2147
Labels
Comments
the-mikedavis
added a commit
to the-mikedavis/helix
that referenced
this issue
May 5, 2022
Inserting a newline currently collapses the any connected selections, when inserting (i) or appending (a). It's happening because we're reducing the selections down to their cursors (`let selection = ..` line) and then computing the new selection based on the cursor. We're discarding the original head and anchor information which are necessary to emulate Kakoune's behavior. In Kakoune, inserting a newline retains the existing selection and _slides_ it (moves head and anchor by the same amount) forward by the newline and indentation amount. Appending extends the selection to include the newline and any new indentation. With the implementation of insert_newline here, we slide by adding the global and local offsets to both head and anchor. We extend by adding the global offset to both head and anchor but the local offset only to the head. closes helix-editor#2147
the-mikedavis
added a commit
to the-mikedavis/helix
that referenced
this issue
May 5, 2022
Inserting a newline currently collapses any connected selections when inserting or appending. It's happening because we're reducing the selections down to their cursors (`let selection = ..` line) and then computing the new selection based on the cursor. We're discarding the original head and anchor information which are necessary to emulate Kakoune's behavior. In Kakoune, inserting a newline retains the existing selection and _slides_ it (moves head and anchor by the same amount) forward by the newline and indentation amount. Appending a newline extends the selection to include the newline and any new indentation. With the implementation of insert_newline here, we slide by adding the global and local offsets to both head and anchor. We extend by adding the global offset to both head and anchor but the local offset only to the head. closes helix-editor#2147
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Summary
Inserting a line break with Enter collapses the selection rather than extending it.
Reproduction Steps
Say we have a buffer like so
(using the selection notation from here)
If we use a to append and then hit Enter in insert mode, the selection becomes
Other non-Enter keys expand the selection as you type. In Kakoune, the selection expands even when inserting line breaks.
Originally discussed here: #943 (comment)
Helix log
No response
Platform
Linux (NixOS 21.11)
Terminal Emulator
kitty 0.23.1
Helix Version
helix 22.05-dev (c45fb08)
The text was updated successfully, but these errors were encountered: