all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Alexander Miller <alexanderm@web.de>
Cc: 26445@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	[thread overview]
Message-ID: <CAM-tV-_Ok4+PYx_1C4-NorNkgP7etgjT4_PuEF4F0bUt8_YJVA@mail.gmail.com> (raw)
In-Reply-To: <624e8d20-8e9f-f164-d9e8-b81659eec2f7@web.de>

found 26445 24.5
tag 26445 confirmed
severity 26445 minor
quit

On Tue, Apr 11, 2017 at 12:50 PM, Alexander Miller <alexanderm@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;





  reply	other threads:[~2017-04-13 19:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-11 16:50 bug#26445: 26.0.50; Scroll margin and cursor movement working incorrectly when scrolling over different height lines Alexander Miller
2017-04-13 19:09 ` Noam Postavsky [this message]
2017-04-13 19:39   ` Eli Zaretskii
2017-04-13 20:05     ` Noam Postavsky
2017-04-13 21:07       ` Alexander Miller
2017-04-14  7:06         ` Eli Zaretskii
2017-04-14  7:46           ` Eli Zaretskii
2017-04-14 10:56           ` Alexander Miller
2017-04-14 12:16             ` Eli Zaretskii
     [not found]               ` <fa0f7cdf-fda4-ce15-9ff8-37ea1767c771@web.de>
2017-04-14 16:07                 ` Eli Zaretskii
2017-04-14  6:50       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM-tV-_Ok4+PYx_1C4-NorNkgP7etgjT4_PuEF4F0bUt8_YJVA@mail.gmail.com \
    --to=npostavs@users.sourceforge.net \
    --cc=26445@debbugs.gnu.org \
    --cc=alexanderm@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.