emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 5e6481b 2/2: Fix cursor position in Dired buffers a


From: Eli Zaretskii
Subject: [Emacs-diffs] master 5e6481b 2/2: Fix cursor position in Dired buffers after dired-sort-toggle
Date: Fri, 2 Jun 2017 05:55:49 -0400 (EDT)

branch: master
commit 5e6481bdc57912ff31c92c5df85e22b5f8ede99d
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Fix cursor position in Dired buffers after dired-sort-toggle
    
    * src/xdisp.c (display_and_set_cursor): Record cursor coordinates
    even if the frame is marked as garbaged.  (Bug#27187)
---
 src/xdisp.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index 53210e5..17a1cae 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -28793,7 +28793,6 @@ display_and_set_cursor (struct window *w, bool on,
      be in the midst of changing its size, and x and y may be off the
      window.  */
   if (! FRAME_VISIBLE_P (f)
-      || FRAME_GARBAGED_P (f)
       || vpos >= w->current_matrix->nrows
       || hpos >= w->current_matrix->matrix_w)
     return;
@@ -28811,6 +28810,26 @@ display_and_set_cursor (struct window *w, bool on,
       return;
     }
 
+  /* A frame might be marked garbaged even though its cursor position
+     is correct, and will not change upon subsequent redisplay.  This
+     happens in some rare situations, like toggling the sort order in
+     Dired windows.  We've already established that VPOS is valid, so
+     it shouldn't do any harm to record the cursor position, as we are
+     going to return without acting on it anyway.  Otherwise, expose
+     events might come in and call update_window_cursor, which will
+     blindly use outdated values in w->phys_cursor.  */
+  if (FRAME_GARBAGED_P (f))
+    {
+      if (on)
+       {
+         w->phys_cursor.x = x;
+         w->phys_cursor.y = glyph_row->y;
+         w->phys_cursor.hpos = hpos;
+         w->phys_cursor.vpos = vpos;
+       }
+      return;
+    }
+
   glyph = NULL;
   if (0 <= hpos && hpos < glyph_row->used[TEXT_AREA])
     glyph = glyph_row->glyphs[TEXT_AREA] + hpos;



reply via email to

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