-
-
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
Use range positions to determine insert_newline motion #9448
Conversation
helix-term/src/commands.rs
Outdated
@@ -3650,8 +3650,7 @@ pub mod insert { | |||
|
|||
(pos, pos, local_offs) | |||
}; | |||
|
|||
let new_range = if doc.restore_cursor { | |||
let new_range = if range.head > range.anchor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will also extend if you enter insert mode via o
(open_below
), O
(open_above
), or mouse click when in insert mode and then hit enter. Instead I believe we want to check range.cursor(text) > range.anchor
to avoid cases where the range is a point (Range::point
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. However, I am not too familiar with range.cursor(text)
. I have run it and it seems to be working fine for my use-cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure that this is the correct condition. I will test this out locally for a while to see if I can find any cases where we extend unexpectedly
I agree this is correct and inline with how other commands work. I would actually go further: There is only one other place where we use |
👍 That would fix the other behavior mentioned in #9443 |
0f15c71
to
19d2e74
Compare
Looks like this needs a run of |
19d2e74
to
40f0e0e
Compare
…9448) * use anchor and head positions to determine motion * use range cursor to decide extending or shifting * add condition to cursor moving back on normal
…9448) * use anchor and head positions to determine motion * use range cursor to decide extending or shifting * add condition to cursor moving back on normal
…9448) * use anchor and head positions to determine motion * use range cursor to decide extending or shifting * add condition to cursor moving back on normal
…9448) * use anchor and head positions to determine motion * use range cursor to decide extending or shifting * add condition to cursor moving back on normal
Fixes #9443
Uses the relative postion of the anchor and the head of a selection to determine whether to shift the selection or to extend it.