diff options
| author | Eli Zaretskii | 2017-06-02 12:53:57 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-06-02 12:53:57 +0300 |
| commit | 5e6481bdc57912ff31c92c5df85e22b5f8ede99d (patch) | |
| tree | 1d7108ab3e0817234787e91e9f0a96a6a3f64248 | |
| parent | 800602b3835d1dcb13dda9319676fe92ad3505fd (diff) | |
| download | emacs-5e6481bdc57912ff31c92c5df85e22b5f8ede99d.tar.gz emacs-5e6481bdc57912ff31c92c5df85e22b5f8ede99d.zip | |
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)
| -rw-r--r-- | src/xdisp.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 53210e5be5b..17a1cae0048 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -28793,7 +28793,6 @@ display_and_set_cursor (struct window *w, bool on, | |||
| 28793 | be in the midst of changing its size, and x and y may be off the | 28793 | be in the midst of changing its size, and x and y may be off the |
| 28794 | window. */ | 28794 | window. */ |
| 28795 | if (! FRAME_VISIBLE_P (f) | 28795 | if (! FRAME_VISIBLE_P (f) |
| 28796 | || FRAME_GARBAGED_P (f) | ||
| 28797 | || vpos >= w->current_matrix->nrows | 28796 | || vpos >= w->current_matrix->nrows |
| 28798 | || hpos >= w->current_matrix->matrix_w) | 28797 | || hpos >= w->current_matrix->matrix_w) |
| 28799 | return; | 28798 | return; |
| @@ -28811,6 +28810,26 @@ display_and_set_cursor (struct window *w, bool on, | |||
| 28811 | return; | 28810 | return; |
| 28812 | } | 28811 | } |
| 28813 | 28812 | ||
| 28813 | /* A frame might be marked garbaged even though its cursor position | ||
| 28814 | is correct, and will not change upon subsequent redisplay. This | ||
| 28815 | happens in some rare situations, like toggling the sort order in | ||
| 28816 | Dired windows. We've already established that VPOS is valid, so | ||
| 28817 | it shouldn't do any harm to record the cursor position, as we are | ||
| 28818 | going to return without acting on it anyway. Otherwise, expose | ||
| 28819 | events might come in and call update_window_cursor, which will | ||
| 28820 | blindly use outdated values in w->phys_cursor. */ | ||
| 28821 | if (FRAME_GARBAGED_P (f)) | ||
| 28822 | { | ||
| 28823 | if (on) | ||
| 28824 | { | ||
| 28825 | w->phys_cursor.x = x; | ||
| 28826 | w->phys_cursor.y = glyph_row->y; | ||
| 28827 | w->phys_cursor.hpos = hpos; | ||
| 28828 | w->phys_cursor.vpos = vpos; | ||
| 28829 | } | ||
| 28830 | return; | ||
| 28831 | } | ||
| 28832 | |||
| 28814 | glyph = NULL; | 28833 | glyph = NULL; |
| 28815 | if (0 <= hpos && hpos < glyph_row->used[TEXT_AREA]) | 28834 | if (0 <= hpos && hpos < glyph_row->used[TEXT_AREA]) |
| 28816 | glyph = glyph_row->glyphs[TEXT_AREA] + hpos; | 28835 | glyph = glyph_row->glyphs[TEXT_AREA] + hpos; |