emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 6acff25: Avoid assertion violations when scrolling


From: Eli Zaretskii
Subject: [Emacs-diffs] master 6acff25: Avoid assertion violations when scrolling narrowed buffer
Date: Mon, 5 Sep 2016 16:58:13 +0000 (UTC)

branch: master
commit 6acff25280dbb97b5e9ddfd872b33ceb36b0470a
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Avoid assertion violations when scrolling narrowed buffer
    
    * src/window.c (window_scroll_pixel_based):
    * src/xdisp.c (pos_visible_p): Don't allow simulated redisplay to
    start outside the accessible portion of the buffer.  This avoids
    assertion violations when some Lisp narrows the buffer to less
    than the current window, and then attempts to scroll the buffer.
---
 src/window.c |    5 +++--
 src/xdisp.c  |    5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/window.c b/src/window.c
index 374ef0f..753ebc1 100644
--- a/src/window.c
+++ b/src/window.c
@@ -4813,8 +4813,9 @@ window_scroll_pixel_based (Lisp_Object window, int n, 
bool whole, bool noerror)
   SET_TEXT_POS_FROM_MARKER (start, w->start);
   /* Scrolling a minibuffer window via scroll bar when the echo area
      shows long text sometimes resets the minibuffer contents behind
-     our backs.  */
-  if (CHARPOS (start) > ZV)
+     our backs.  Also, someone might narrow-to-region and immediately
+     call a scroll function.  */
+  if (CHARPOS (start) > ZV || CHARPOS (start) < BEGV)
     SET_TEXT_POS (start, BEGV, BEGV_BYTE);
 
   /* If PT is not visible in WINDOW, move back one half of
diff --git a/src/xdisp.c b/src/xdisp.c
index dc68cd4..d1e8848 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1317,8 +1317,9 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int 
*x, int *y,
   SET_TEXT_POS_FROM_MARKER (top, w->start);
   /* Scrolling a minibuffer window via scroll bar when the echo area
      shows long text sometimes resets the minibuffer contents behind
-     our backs.  */
-  if (CHARPOS (top) > ZV)
+     our backs.  Also, someone might narrow-to-region and immediately
+     call a scroll function.  */
+  if (CHARPOS (top) > ZV || CHARPOS (top) < BEGV)
     SET_TEXT_POS (top, BEGV, BEGV_BYTE);
 
   /* If the top of the window is after CHARPOS, the latter is surely



reply via email to

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