emacs-diffs
[Top][All Lists]
Advanced

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

feature/fix-the-long-lines-display-bug c0c4600ece: Fix calculation of th


From: Eli Zaretskii
Subject: feature/fix-the-long-lines-display-bug c0c4600ece: Fix calculation of the vertical scroll bar's thumb
Date: Fri, 8 Jul 2022 02:43:39 -0400 (EDT)

branch: feature/fix-the-long-lines-display-bug
commit c0c4600eceaed7134918437db9a5ea9c0e4b0c18
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.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 | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index 7821c120ca..0b88b434bc 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -18872,19 +18872,34 @@ 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);
+       }
       if (! BUFFER_AUTO_NARROWED_P (buf))
        {
          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);
        }
       else
        {
          whole = BUF_Z (buf) - BUF_BEG (buf);
          start = marker_position (w->start) - BUF_BEG (buf);
-         end = BUF_Z (buf) - w->window_end_pos - BUF_BEG (buf);
+         end = BUF_Z (buf) - window_end_pos - BUF_BEG (buf);
        }
 
       if (end < start)



reply via email to

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