emacs-devel
[Top][All Lists]
Advanced

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

Re: feature/fix-the-long-lines-display-bug 0699f80f85 1/2: Fix calculati


From: Po Lu
Subject: Re: feature/fix-the-long-lines-display-bug 0699f80f85 1/2: Fix calculation of the vertical scroll bar's thumb
Date: Tue, 19 Jul 2022 08:59:05 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux)

Gregory Heytings <gregory@heytings.org> writes:

> branch: feature/fix-the-long-lines-display-bug
> commit 0699f80f851b1f9e2f7b0a22ddd688abb7bebde1
> Author: Eli Zaretskii <eliz@gnu.org>
> Commit: Gregory Heytings <gregory@heytings.org>
>
>     Fix calculation of the vertical scroll bar's thumb
>     
>     * src/xdisp.c (set_vertical_scroll_bar): Compute window's end
>     position "by hand" if w->window_end_pos cannot be relied upon.
> ---
>  src/xdisp.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/src/xdisp.c b/src/xdisp.c
> index 375158a520..ae6553d876 100644
> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -18924,11 +18924,27 @@ set_vertical_scroll_bar (struct window *w)
>         && NILP (echo_area_buffer[0])))
>      {
>        struct buffer *buf = XBUFFER (w->contents);
> +      ptrdiff_t window_end_pos = w->window_end_pos;
> +
> +      /* If w->window_end_pos cannot be trusted, recompute it "the
> +      hard way".  */
> +      if (!w->window_end_valid)
> +     {
> +       struct it it;
> +       struct text_pos start_pos;
> +
> +       SET_TEXT_POS_FROM_MARKER (start_pos, w->start);
> +       start_display (&it, w, start_pos);
> +       move_it_to (&it, -1, it.last_visible_x, window_box_height (w), -1,
> +                   MOVE_TO_X | MOVE_TO_Y);
> +       window_end_pos = BUF_Z (buf) - IT_CHARPOS (it);
> +     }
> +
>        whole = BUF_ZV (buf) - BUF_BEGV (buf);
>        start = marker_position (w->start) - BUF_BEGV (buf);
>        /* I don't think this is guaranteed to be right.  For the
>        moment, we'll pretend it is.  */
> -      end = BUF_Z (buf) - w->window_end_pos - BUF_BEGV (buf);
> +      end = BUF_Z (buf) - window_end_pos - BUF_BEGV (buf);
>  
>        if (end < start)
>       end = start;

When making changes of this kind, you should test without toolkit scroll
bars, and with at least both the Motif (with
scroll-bar-adjust-thumb-position both on and off) and Xaw scroll bars to
make sure they still work correctly.  Testing on NS also helps, since
the scroll bar logic there is somewhat different.

The last time I tried to significantly change the scroll bar logic (to
operate on more realistic positions within a window), those specific
configurations bit me hard.


reply via email to

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