bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#19060: [FIX INCLUDED] Off-by-one-line scrolling bug in window_scroll


From: Eli Zaretskii
Subject: bug#19060: [FIX INCLUDED] Off-by-one-line scrolling bug in window_scroll_pixel_based
Date: Sat, 15 Nov 2014 11:27:05 +0200

> From: Kelly Dean <kelly@prtime.org>
> Date: Sat, 15 Nov 2014 06:57:45 +0000
> 
> With 24.4, emacs -Q, then M-x split-window-horizontally, then open any file 
> with a lot of long logical lines (each a few visual lines long), so that as 
> you page down through the file, every screenful of text has some wrapped 
> lines on it. Adjust the vertical size of your Emacs frame so that the 
> vertical size of your Emacs windows is not an integer multiple of the visual 
> line height, so that the bottom visual line of text is partially covered by 
> the top of the mode line.
> Scroll forward a couple pages using pgdn (scroll-up-command), then notice 
> exactly which visual line is at the top, and which one is at the bottom. 
> Press pgdn, then pgup, and notice that the text doesn't return to the 
> previous position; instead, it's scrolled backward by one visual line. This 
> bug wasn't in 24.3.
> 
> The bug is in window.c of the 24.4 release, line 5042. The fix is to change 
> ⌜window_box_height (w)⌝ on that line to ⌜window_box_height (w) / dy * dy⌝ in 
> order to align the result to an integer multiple of the visual line height, 
> since as of 24.4, Emacs no longer ensures that window_box_height is such a 
> multiple. Patch excluded, per request.
> 
> There might be a related bug (with the same fix) on line 4959, but I haven't 
> tested that.


Martin, I propose the following patch:

diff --git a/src/window.c b/src/window.c
index b002423..7462fdc 100644
--- a/src/window.c
+++ b/src/window.c
@@ -4956,8 +4956,8 @@ window_scroll_pixel_based (Lisp_Object window, int n, 
bool whole, int noerror)
          int px;
          int dy = frame_line_height;
          if (whole)
-           dy = max ((window_box_height (w)
-                      - next_screen_context_lines * dy),
+           dy = max ((window_box_height (w) / dy
+                      - next_screen_context_lines) * dy,
                      dy);
          dy *= n;
 
@@ -5039,8 +5039,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, 
bool whole, int noerror)
     {
       ptrdiff_t start_pos = IT_CHARPOS (it);
       int dy = frame_line_height;
-      dy = max ((window_box_height (w)
-                - next_screen_context_lines * dy),
+      dy = max ((window_box_height (w) / dy - next_screen_context_lines) * dy,
                dy) * n;
 
       /* Note that move_it_vertically always moves the iterator to the


> BTW on line 471 (copied from line 466) of window.h, ‟width” should be 
> ‟height”.

Indeed, and "column" should be "line".  Thanks, fixed.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]