GNU bug report logs - #26445
26.0.50; Scroll margin and cursor movement working incorrectly when scrolling over different height lines

Previous Next

Package: emacs;

Reported by: Alexander Miller <alexanderm <at> web.de>

Date: Tue, 11 Apr 2017 16:52:02 UTC

Severity: minor

Tags: confirmed, notabug

Found in versions 26.0.50, 24.5

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: Alexander Miller <alexanderm <at> web.de>
Cc: 26445 <at> debbugs.gnu.org
Subject: bug#26445: 26.0.50; Scroll margin and cursor movement working incorrectly when scrolling over different height lines
Date: Thu, 13 Apr 2017 15:09:14 -0400
found 26445 24.5
tag 26445 confirmed
severity 26445 minor
quit

On Tue, Apr 11, 2017 at 12:50 PM, Alexander Miller <alexanderm <at> web.de> wrote:
> This is probably a continuation of bug#25792.

The symptoms are similar, but this one seems to be a long-standing
bug, I get the same behaviour in 24.5 (haven't tested earlier
versions, but I wouldn't expect anything different).

This code in `try_cursor_movement' is what's different for scrolling
vs non-scrolling lines.

          /* If within the scroll margin, scroll.  Note that
         MATRIX_ROW_BOTTOM_Y gives the pixel position at which
         the next line would be drawn, and that
         this_scroll_margin can be zero.  */
          if (MATRIX_ROW_BOTTOM_Y (row) > last_y
          || PT > MATRIX_ROW_END_CHARPOS (row)
          /* Line is completely visible last line in window
             and PT is to be set in the next line.  */
          || (MATRIX_ROW_BOTTOM_Y (row) == last_y
              && PT == MATRIX_ROW_END_CHARPOS (row)
              && !row->ends_at_zv_p
              && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row)))
        scroll_p = true;

I think the root issue might be that scroll-margin is given in lines,
and then it's translated to pixels under the assumption that lines are
all using the default height. Although my initial attempt to make
window_scroll_margin take different line heights into account doesn't
seem to have any effect. AFAICT, the next test, PT >
MATRIX_ROW_END_CHARPOS (row), just triggers instead.

modified   src/window.c
@@ -4820,10 +4820,17 @@ window_scroll_margin (struct window *window,
enum margin_unit unit)
         }
       int max_margin = min ((window_lines - 1)/2,
                             (int) (window_lines * ratio));
-      int margin = clip_to_bounds (0, scroll_margin, max_margin);
-      return (unit == MARGIN_IN_PIXELS)
-        ? margin * frame_line_height
-        : margin;
+      int margin_lines = clip_to_bounds (0, scroll_margin, max_margin);
+      if (unit == MARGIN_IN_LINES)
+          return margin_lines;
+      else
+        {
+          struct it it;
+          init_iterator (&it, window, BEGV, BEGV_BYTE, NULL, DEFAULT_FACE_ID);
+          move_it_to (&it, -1, -1, it.last_visible_y, -1, MOVE_TO_Y);
+          move_it_by_lines (&it, -margin_lines);
+          return it.last_visible_y - it.current_y;
+        }
     }
   else
     return 0;




This bug report was last modified 8 years and 38 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.