diff options
author | Eli Zaretskii <eliz@gnu.org> | 2018-06-06 18:28:44 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2018-06-06 18:28:44 +0300 |
commit | e5ab25deaeb5daf58d2e3b0c990cd67e6020bb38 (patch) | |
tree | 581e449920bba48915918905bd040926868c65e1 /lisp/simple.el | |
parent | d20beef5f104909f765430e347f5f3711ea51149 (diff) | |
download | emacs-e5ab25deaeb5daf58d2e3b0c990cd67e6020bb38.tar.gz emacs-e5ab25deaeb5daf58d2e3b0c990cd67e6020bb38.tar.bz2 emacs-e5ab25deaeb5daf58d2e3b0c990cd67e6020bb38.zip |
Fix cursor movement by 'next-logical-line' after 'next-line'
* src/indent.c (Fvertical_motion): Adjust TO_X when line-numbers
are being displayed. Remove unneeded "correction" of TO_X at the
goal line.
* lisp/simple.el (last--line-number-width): Remove unneeded
variable.
(line-move-visual): Account for line-number display width by
adjusting the pixel X coordinate that gets converted into
canonical columns passed to vertical-motion, instead of adjusting
temporary-goal-column (which then affects next commands, including
next-logical-line). (Bug#31723)
Diffstat (limited to 'lisp/simple.el')
-rw-r--r-- | lisp/simple.el | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index bcf2b067704..cbad75193a4 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5972,10 +5972,6 @@ columns by which window is scrolled from left margin. When the `track-eol' feature is doing its job, the value is `most-positive-fixnum'.") -(defvar last--line-number-width 0 - "Last value of width used for displaying line numbers. -Used internally by `line-move-visual'.") - (defcustom line-move-ignore-invisible t "Non-nil means commands that move by lines ignore invisible newlines. When this option is non-nil, \\[next-line], \\[previous-line], \\[move-end-of-line], and \\[move-beginning-of-line] behave @@ -6254,19 +6250,9 @@ If NOERROR, don't signal an error if we can't move that many lines." (memq last-command `(next-line previous-line ,this-command))) ;; If so, there's no need to reset `temporary-goal-column', ;; but we may need to hscroll. - (progn - (if (or (/= (cdr temporary-goal-column) hscroll) - (> (cdr temporary-goal-column) 0)) - (setq target-hscroll (cdr temporary-goal-column))) - ;; Update the COLUMN part of temporary-goal-column if the - ;; line-number display changed its width since the last - ;; time. - (setq temporary-goal-column - (cons (+ (car temporary-goal-column) - (/ (float (- lnum-width last--line-number-width)) - (frame-char-width))) - (cdr temporary-goal-column))) - (setq last--line-number-width lnum-width)) + (if (or (/= (cdr temporary-goal-column) hscroll) + (> (cdr temporary-goal-column) 0)) + (setq target-hscroll (cdr temporary-goal-column))) ;; Otherwise, we should reset `temporary-goal-column'. (let ((posn (posn-at-point)) x-pos) @@ -6276,7 +6262,7 @@ If NOERROR, don't signal an error if we can't move that many lines." ((memq (nth 1 posn) '(right-fringe left-fringe)) (setq temporary-goal-column (cons (window-width) hscroll))) ((car (posn-x-y posn)) - (setq x-pos (car (posn-x-y posn))) + (setq x-pos (- (car (posn-x-y posn)) lnum-width)) ;; In R2L lines, the X pixel coordinate is measured from the ;; left edge of the window, but columns are still counted ;; from the logical-order beginning of the line, i.e. from |