emacs-diffs
[Top][All Lists]
Advanced

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

master 12a3137cd3: Fix display of scroll-bar in mini-windows


From: Eli Zaretskii
Subject: master 12a3137cd3: Fix display of scroll-bar in mini-windows
Date: Fri, 22 Jul 2022 09:16:44 -0400 (EDT)

branch: master
commit 12a3137cd381cb743768033e789b900b015041d7
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix display of scroll-bar in mini-windows
    
    * src/xdisp.c (set_vertical_scroll_bar): Ensure current_buffer is
    set correctly when displaying scroll bar of a mini-window.
    (Bug#56692)
---
 src/xdisp.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index 88e2db8956..629524eee4 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -18930,28 +18930,30 @@ 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;
+
+      whole = BUF_ZV (buf) - BUF_BEGV (buf);
+      start = marker_position (w->start) - BUF_BEGV (buf);
+      end = BUF_Z (buf) - w->window_end_pos - BUF_BEGV (buf);
 
       /* If w->window_end_pos cannot be trusted, recompute it "the
-        hard way".  Unless W is a minibuffer window, in which case
-        w->window_end_pos is specially set?  (bug#56692) */
-      if (!MINI_WINDOW_P (w)
-         && !w->window_end_valid)
+        hard way".  */
+      if (!MINI_WINDOW_P (w))
        {
          struct it it;
          struct text_pos start_pos;
-
+         struct buffer *obuf = current_buffer;
+         /* When we display the scroll bar of a mini-window,
+            current_buffer is not gauranteed to be the mini-window's
+            buffer, see the beginning of redisplay_window.  */
+         set_buffer_internal_1 (XBUFFER (w->contents));
          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);
+         end -= (BUF_Z (buf) - IT_CHARPOS (it)) - w->window_end_pos;
+         set_buffer_internal_1 (obuf);
        }
 
-      whole = BUF_ZV (buf) - BUF_BEGV (buf);
-      start = marker_position (w->start) - BUF_BEGV (buf);
-      end = BUF_Z (buf) - window_end_pos - BUF_BEGV (buf);
-
       if (end < start)
        end = start;
       if (whole < (end - start))



reply via email to

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