[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-26 e5ab25d: Fix cursor movement by 'next-logical-lin
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] emacs-26 e5ab25d: Fix cursor movement by 'next-logical-line' after 'next-line' |
Date: |
Wed, 6 Jun 2018 11:29:25 -0400 (EDT) |
branch: emacs-26
commit e5ab25deaeb5daf58d2e3b0c990cd67e6020bb38
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
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)
---
lisp/simple.el | 22 ++++------------------
src/indent.c | 10 +++-------
2 files changed, 7 insertions(+), 25 deletions(-)
diff --git a/lisp/simple.el b/lisp/simple.el
index bcf2b06..cbad751 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
diff --git a/src/indent.c b/src/indent.c
index 316171e..bcffa0d 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -2278,7 +2278,9 @@ whether or not it is currently displayed in some window.
*/)
overshoot_handled = 1;
}
if (lcols_given)
- to_x = window_column_x (w, window, extract_float (lcols), lcols);
+ to_x =
+ window_column_x (w, window, extract_float (lcols), lcols)
+ + lnum_pixel_width;
if (nlines <= 0)
{
it.vpos = vpos_init;
@@ -2330,12 +2332,6 @@ whether or not it is currently displayed in some window.
*/)
an addition to the hscroll amount. */
if (lcols_given)
{
- /* If we are displaying line numbers, we could cross the
- line where the width of the line-number display changes,
- in which case we need to fix up the pixel coordinate
- accordingly. */
- if (lnum_pixel_width > 0)
- to_x += it.lnum_pixel_width - lnum_pixel_width;
move_it_in_display_line (&it, ZV, first_x + to_x, MOVE_TO_X);
/* If we find ourselves in the middle of an overlay string
which includes a newline after current string position,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-26 e5ab25d: Fix cursor movement by 'next-logical-line' after 'next-line',
Eli Zaretskii <=