Skip to content

vim: Make end of line infallible#48867

Merged
dinocosta merged 1 commit intomainfrom
48855-end-of-line
Feb 10, 2026
Merged

vim: Make end of line infallible#48867
dinocosta merged 1 commit intomainfrom
48855-end-of-line

Conversation

@dinocosta
Copy link
Member

@dinocosta dinocosta commented Feb 10, 2026

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.

These changes 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.

Closes #48855

  • Tests or screenshots needed?
  • Code Reviewed
  • Manual QA

Release Notes:

  • vim: Fixed $ not sticking to end-of-line on vertical motions (j/k) when the cursor was already at the end of the line via l or arrow keys

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.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 10, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Feb 10, 2026
@dinocosta dinocosta enabled auto-merge (squash) February 10, 2026 10:28
@dinocosta dinocosta merged commit ad7b1f5 into main Feb 10, 2026
36 checks passed
@dinocosta dinocosta deleted the 48855-end-of-line branch February 10, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vim $ does not move to end of line when cursor is already at end of short line, then moving to longer line of text

1 participant