Conversation
When using `$` to move to the end of line (`vim::EndOfLine`), the `vim::motion::Motion.move_point` method checks whether the new point, that is, the point after the motion is applied is different from the point that was passed as a method argument. If the point is not different, the point and selection goals are only updated if `vim::motion::Motion.infallible` returns true for the motion in question. In short, this means that, if the cursor was already at the end of the line, and it got there using `vim::Right`, for example, the selection goal wouldn't actually be set to `SelectionGoal::HorizontalPosition(f64::INFINITY)`, so when the cursor was moved to a shorter line, it wouldn't be set at the end of that line, even though `$` had been used. This commit updates `vim::motion::Motion.infallible` to ensure that, for `vim::motion::Motion::EndOfLine`, it returns `true`, so that the selection goal is always updated, regardless of whether the cursor is already at the end of the line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using
$to move to the end of line (vim::EndOfLine), thevim::motion::Motion.move_pointmethod checks whether the new point, that is, the point after the motion is applied is different from the point that was passed as a method argument. If the point is not different, the point and selection goals are only updated ifvim::motion::Motion.infalliblereturns true for the motion in question.In short, this means that, if the cursor was already at the end of the line, and it got there using
vim::Right, for example, the selection goal wouldn't actually be set toSelectionGoal::HorizontalPosition(f64::INFINITY), so when the cursor was moved to a shorter line, it wouldn't be set at the end of that line, even though$had been used.These changes updates
vim::motion::Motion.infallibleto ensure that, forvim::motion::Motion::EndOfLine, it returnstrue, so that the selection goal is always updated, regardless of whether the cursor is already at the end of the line.Closes #48855
Release Notes:
$not sticking to end-of-line on vertical motions (j/k) when the cursor was already at the end of the line vialor arrow keys