From 86f7c0fe6000de85d8b282da761e65e18a73b287 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 4 Feb 2013 17:39:55 +0200 Subject: [PATCH] Fix bugs #13623 and 13626 caused by changes in 2013-02-01T07:23:18Z!dmantipov@yandex.ru. src/xdisp.c (window_buffer_changed): region_showing can be negative, which still means region is being displayed. (redisplay_internal): Resurrect code that forced redisplay of the whole window when showing region and the mark has changed. Record the new mark position to allow redisplay optimizations. (display_line): If it->region_beg_charpos is non-zero, set the window's region_showing member to -1. src/window.h (struct window) : Declare ptrdiff_t, not bitfield of 1 bit. --- src/ChangeLog | 13 +++++++++++++ src/window.h | 8 +++++--- src/xdisp.c | 17 +++++++++++++++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 1c7771cb0d9..6f52f764a97 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2013-02-04 Eli Zaretskii + + * xdisp.c (window_buffer_changed): region_showing can be negative, + which still means region is being displayed. + (redisplay_internal): Resurrect code that forced redisplay of the + whole window when showing region and the mark has changed. Record + the new mark position to allow redisplay optimizations. + (display_line): If it->region_beg_charpos is non-zero, set the + window's region_showing member to -1. (Bug#13623) (Bug#13626) + + * window.h (struct window) : Declare ptrdiff_t, + not bitfield of 1 bit. + 2013-02-03 Daniel Colascione * emacs.c: Use execvp, not execv, when DAEMON_MUST_EXEC, so that diff --git a/src/window.h b/src/window.h index f28ce1424d0..0f4f242641e 100644 --- a/src/window.h +++ b/src/window.h @@ -333,13 +333,15 @@ struct window the frame image that window_end_pos did not get onto the frame. */ unsigned window_end_valid : 1; - /* Nonzero if we have highlighted the region (or any part of it). */ - unsigned region_showing : 1; - /* Amount by which lines of this window are scrolled in y-direction (smooth scrolling). */ int vscroll; + /* If we have highlighted the region (or any part of it), the mark + position or -1 (the latter is used by the iterator for internal + purposes); otherwise zero. */ + ptrdiff_t region_showing; + /* Z_BYTE - buffer position of the last glyph in the current matrix of W. Should be nonnegative, and only valid if window_end_valid is nonzero. */ ptrdiff_t window_end_bytepos; diff --git a/src/xdisp.c b/src/xdisp.c index 7b6e108d97f..a958fd51e39 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -10753,7 +10753,7 @@ window_buffer_changed (struct window *w) return (((BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)) != w->last_had_star) || ((!NILP (Vtransient_mark_mode) && !NILP (BVAR (b, mark_active))) - != w->region_showing)); + != (w->region_showing != 0))); } /* Nonzero if W has %c in its mode line and mode line should be updated. */ @@ -13016,6 +13016,17 @@ redisplay_internal (void) clear_garbaged_frames (); } + /* If showing the region, and mark has changed, we must redisplay + the whole window. The assignment to this_line_start_pos prevents + the optimization directly below this if-statement. */ + if (((!NILP (Vtransient_mark_mode) + && !NILP (BVAR (XBUFFER (w->buffer), mark_active))) + != (w->region_showing > 0)) + || (w->region_showing + && w->region_showing + != XINT (Fmarker_position (BVAR (XBUFFER (w->buffer), mark))))) + CHARPOS (this_line_start_pos) = 0; + /* Optimize the case that only the line containing the cursor in the selected window has changed. Variables starting with this_ are set in display_line and record information about the line @@ -13228,6 +13239,8 @@ redisplay_internal (void) ++clear_image_cache_count; #endif + w->region_showing = XINT (Fmarker_position (BVAR (XBUFFER (w->buffer), mark))); + /* Build desired matrices, and update the display. If consider_all_windows_p is non-zero, do it for all windows on all frames. Otherwise do it for selected_window, only. */ @@ -19120,7 +19133,7 @@ display_line (struct it *it) } /* Is IT->w showing the region? */ - it->w->region_showing = it->region_beg_charpos > 0; + it->w->region_showing = it->region_beg_charpos > 0 ? -1 : 0; /* Clear the result glyph row and enable it. */ prepare_desired_row (row); -- 2.39.5