vim: Fix cursor position being set to end of line in normal mode (#38161)
Dino
and
Conrad Irwin
created
Address an issue where, in Vim mode, clicking past the end of a line
after selecting the entire line would place the cursor on the newline
character instead of the last character of the line, which is
inconsistent with Vim's normal mode expectations.
I believe the root cause was that the cursor’s position was updated to
the end of the line before the mode switch from Visual to Normal, at
which point `DisplayMap.clip_at_line_ends` was still set to `false`. As
a result, the cursor could end up in an invalid position for Normal
mode. The fix ensures that when switching between these two modes, and
if the selection is empty, the selection point is properly clipped,
preventing the cursor from being placed past the end of the line.
Related #38049
Release Notes:
- Fixed issue in Vim mode where switching from any mode to normal mode
could end up with the cursor in the newline character
---------
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>