Commit 5e6481bd authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

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)
parent 800602b3
......@@ -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. */
|| vpos >= w->current_matrix->nrows
|| hpos >= w->current_matrix->matrix_w)
......@@ -28811,6 +28810,26 @@ display_and_set_cursor (struct window *w, bool on,
/* 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 (on)
w->phys_cursor.x = x;
w->phys_cursor.y = glyph_row->y;
w->phys_cursor.hpos = hpos;
w->phys_cursor.vpos = vpos;
glyph = NULL;
if (0 <= hpos && hpos < glyph_row->used[TEXT_AREA])
glyph = glyph_row->glyphs[TEXT_AREA] + hpos;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment