From: Eli Zaretskii Date: Thu, 21 Jan 2021 14:21:45 +0000 (+0200) Subject: A better fix for 'kill-visual-line' X-Git-Tag: emacs-28.0.90~4170 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b2d30fd6303a2461c591f0ace7eb2a43638bba21;p=emacs.git A better fix for 'kill-visual-line' * lisp/simple.el (kill-visual-line): Use the 6th element of the return value of 'posn-at-point', which provides the coordinates in terms or row and column, and is thus more reliable for deciding whether we moved to the next screen line. (Bug#45837) --- diff --git a/lisp/simple.el b/lisp/simple.el index 37c0885dcc5..2c6e3916cd4 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -7338,10 +7338,7 @@ even beep.)" ;; of the kill before killing. (let ((opoint (point)) (kill-whole-line (and kill-whole-line (bolp))) - (orig-y (cdr (nth 2 (posn-at-point)))) - ;; FIXME: This tolerance should be zero! It isn't due to a - ;; bug in posn-at-point, see bug#45837. - (tol (/ (line-pixel-height) 2))) + (orig-vlnum (cdr (nth 6 (posn-at-point))))) (if arg (vertical-motion (prefix-numeric-value arg)) (end-of-visual-line 1) @@ -7352,8 +7349,8 @@ even beep.)" ;; end-of-visual-line didn't overshoot due to complications ;; like display or overlay strings, intangible text, etc.: ;; otherwise, we don't want to kill a character that's - ;; unrelated to the place where the visual line wrapped. - (and (< (abs (- (cdr (nth 2 (posn-at-point))) orig-y)) tol) + ;; unrelated to the place where the visual line wraps. + (and (= (cdr (nth 6 (posn-at-point))) orig-vlnum) ;; Make sure we delete the character where the line wraps ;; under visual-line-mode, be it whitespace or a ;; character whose category set allows to wrap at it.