unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Noam Postavsky <npostavs@users.sourceforge.net>
Cc: alexanderm@web.de, 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 22:39:40 +0300	[thread overview]
Message-ID: <83wpaogkqr.fsf@gnu.org> (raw)
In-Reply-To: <CAM-tV-_Ok4+PYx_1C4-NorNkgP7etgjT4_PuEF4F0bUt8_YJVA@mail.gmail.com> (message from Noam Postavsky on Thu, 13 Apr 2017 15:09:14 -0400)

> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Date: Thu, 13 Apr 2017 15:09:14 -0400
> Cc: 26445@debbugs.gnu.org
> 
> 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;

Not sure what you are saying: do you see some problem in the above
code?  If so, where do you see a potential problem.

> 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.

If that's the problem, I see no good solutions here, because
scroll-conservatively > 100 explicitly requests to position point as
close to the window edge as possible, and the alternating lines of
different height in the recipe of this bug report force us to stop one
line earlier every other scroll.  Am I missing something?

> 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.

Not sure how to interpret what you say here.  If point is beyond
MATRIX_ROW_END_CHARPOS of a row, it means point is not in this row,
because MATRIX_ROW_END_CHARPOS gives the buffer position of the first
character in the next row.  There are no coordinates, pixel or
otherwise, involved here.

> 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;
> +        }

Is this a suggested patch?  If so, how can it fix the issue?  When a
line is taller than the canonical height, positioning point on it
might enter the scroll-margin, and we still need to back up, don't we?
IOW, the above code still move "by lines", and will "stutter" if lines
are intermittently of different height.  What possible solution could
we come up with in such situations?  It seems to me that the user gets
what they asked for.





  reply	other threads:[~2017-04-13 19:39 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
2017-04-13 19:39   ` Eli Zaretskii [this message]
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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=83wpaogkqr.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=26445@debbugs.gnu.org \
    --cc=alexanderm@web.de \
    --cc=npostavs@users.sourceforge.net \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).