aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2011-07-22 17:09:51 +0300
committerEli Zaretskii2011-07-22 17:09:51 +0300
commitb6d5a68964e812af176a6217882add25703914b2 (patch)
treef3147e2e5c8e602fcd300f9bf3d04949eab75417 /src
parente8c17b886b93f34bcc89e2dff0510cbf63c1f179 (diff)
downloademacs-b6d5a68964e812af176a6217882add25703914b2.tar.gz
emacs-b6d5a68964e812af176a6217882add25703914b2.zip
Fix previous change that broke faces in bidirectional text.
src/xdisp.c (compute_stop_pos_backwards): New function. (handle_stop_backwards): Revert last change. (next_element_from_buffer): Call compute_stop_pos_backwards to find a suitable prev_stop when we find ourselves before base_level_stop. Remove the funky search for 1000 character positions back.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/xdisp.c82
2 files changed, 70 insertions, 21 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 15f37f486e2..c03acbcfd1c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12011-07-22 Eli Zaretskii <eliz@gnu.org>
2
3 * xdisp.c (compute_stop_pos_backwards): New function.
4 (handle_stop_backwards): Revert last change.
5 (next_element_from_buffer): Call compute_stop_pos_backwards to
6 find a suitable prev_stop when we find ourselves before
7 base_level_stop. Remove the funky search for 1000 character
8 positions back.
9
12011-07-19 Eli Zaretskii <eliz@gnu.org> 102011-07-19 Eli Zaretskii <eliz@gnu.org>
2 11
3 Fix a significant slow-down of vertical-motion when leaning on C-n 12 Fix a significant slow-down of vertical-motion when leaning on C-n
diff --git a/src/xdisp.c b/src/xdisp.c
index 9968fabf2a4..52b1f484939 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -3193,7 +3193,7 @@ compute_display_string_pos (struct text_pos *position,
3193 if (cached_prev_pos 3193 if (cached_prev_pos
3194 && cached_prev_pos < charpos && charpos <= cached_disp_pos) 3194 && cached_prev_pos < charpos && charpos <= cached_disp_pos)
3195 return cached_disp_pos; 3195 return cached_disp_pos;
3196 /* Handle overstepping eather end of the known interval. */ 3196 /* Handle overstepping either end of the known interval. */
3197 if (charpos > cached_disp_pos) 3197 if (charpos > cached_disp_pos)
3198 cached_prev_pos = cached_disp_pos; 3198 cached_prev_pos = cached_disp_pos;
3199 else /* charpos <= cached_prev_pos */ 3199 else /* charpos <= cached_prev_pos */
@@ -7222,6 +7222,50 @@ next_element_from_stretch (struct it *it)
7222 return 1; 7222 return 1;
7223} 7223}
7224 7224
7225/* Scan backwards from IT's current position until we find a stop
7226 position, or until BEGV. This is called when we find ourself
7227 before both the last known prev_stop and base_level_stop while
7228 reordering bidirectional text. */
7229
7230static void
7231compute_stop_pos_backwards (struct it *it)
7232{
7233 const int SCAN_BACK_LIMIT = 1000;
7234 struct text_pos pos;
7235 struct display_pos save_current = it->current;
7236 struct text_pos save_position = it->position;
7237 EMACS_INT charpos = IT_CHARPOS (*it);
7238 EMACS_INT where_we_are = charpos;
7239 EMACS_INT save_stop_pos = it->stop_charpos;
7240 EMACS_INT save_end_pos = it->end_charpos;
7241
7242 xassert (NILP (it->string) && !it->s);
7243 xassert (it->bidi_p);
7244 it->bidi_p = 0;
7245 do
7246 {
7247 it->end_charpos = min (charpos + 1, ZV);
7248 charpos = max (charpos - SCAN_BACK_LIMIT, BEGV);
7249 SET_TEXT_POS (pos, charpos, BYTE_TO_CHAR (charpos));
7250 reseat_1 (it, pos, 0);
7251 compute_stop_pos (it);
7252 /* We must advance forward, right? */
7253 if (it->stop_charpos <= charpos)
7254 abort ();
7255 }
7256 while (charpos > BEGV && it->stop_charpos >= it->end_charpos);
7257
7258 if (it->stop_charpos <= where_we_are)
7259 it->prev_stop = it->stop_charpos;
7260 else
7261 it->prev_stop = BEGV;
7262 it->bidi_p = 1;
7263 it->current = save_current;
7264 it->position = save_position;
7265 it->stop_charpos = save_stop_pos;
7266 it->end_charpos = save_end_pos;
7267}
7268
7225/* Scan forward from CHARPOS in the current buffer/string, until we 7269/* Scan forward from CHARPOS in the current buffer/string, until we
7226 find a stop position > current IT's position. Then handle the stop 7270 find a stop position > current IT's position. Then handle the stop
7227 position before that. This is called when we bump into a stop 7271 position before that. This is called when we bump into a stop
@@ -7239,9 +7283,9 @@ handle_stop_backwards (struct it *it, EMACS_INT charpos)
7239 struct text_pos save_position = it->position; 7283 struct text_pos save_position = it->position;
7240 struct text_pos pos1; 7284 struct text_pos pos1;
7241 EMACS_INT next_stop; 7285 EMACS_INT next_stop;
7242 int found_stop = 0;
7243 7286
7244 /* Scan in strict logical order. */ 7287 /* Scan in strict logical order. */
7288 xassert (it->bidi_p);
7245 it->bidi_p = 0; 7289 it->bidi_p = 0;
7246 do 7290 do
7247 { 7291 {
@@ -7257,10 +7301,6 @@ handle_stop_backwards (struct it *it, EMACS_INT charpos)
7257 /* We must advance forward, right? */ 7301 /* We must advance forward, right? */
7258 if (it->stop_charpos <= it->prev_stop) 7302 if (it->stop_charpos <= it->prev_stop)
7259 abort (); 7303 abort ();
7260 /* Did we find at least one stop_pos between CHARPOS and IT's
7261 current position? */
7262 if (it->stop_charpos <= where_we_are)
7263 found_stop = 1;
7264 charpos = it->stop_charpos; 7304 charpos = it->stop_charpos;
7265 } 7305 }
7266 while (charpos <= where_we_are); 7306 while (charpos <= where_we_are);
@@ -7268,13 +7308,10 @@ handle_stop_backwards (struct it *it, EMACS_INT charpos)
7268 it->bidi_p = 1; 7308 it->bidi_p = 1;
7269 it->current = save_current; 7309 it->current = save_current;
7270 it->position = save_position; 7310 it->position = save_position;
7271 if (found_stop) 7311 next_stop = it->stop_charpos;
7272 { 7312 it->stop_charpos = it->prev_stop;
7273 next_stop = it->stop_charpos; 7313 handle_stop (it);
7274 it->stop_charpos = it->prev_stop; 7314 it->stop_charpos = next_stop;
7275 handle_stop (it);
7276 it->stop_charpos = next_stop;
7277 }
7278} 7315}
7279 7316
7280/* Load IT with the next display element from current_buffer. Value 7317/* Load IT with the next display element from current_buffer. Value
@@ -7369,16 +7406,19 @@ next_element_from_buffer (struct it *it)
7369 embedding level, so test for that explicitly. */ 7406 embedding level, so test for that explicitly. */
7370 && !BIDI_AT_BASE_LEVEL (it->bidi_it)) 7407 && !BIDI_AT_BASE_LEVEL (it->bidi_it))
7371 { 7408 {
7372 EMACS_INT start_from;
7373 /* If we lost track of base_level_stop, we try looking backwards
7374 for at most 1000 characters. This happens, e.g., when we
7375 were reseated to the previous screenful of text by
7376 vertical-motion. */
7377 if (it->base_level_stop <= 0 7409 if (it->base_level_stop <= 0
7378 || IT_CHARPOS (*it) < it->base_level_stop) 7410 || IT_CHARPOS (*it) < it->base_level_stop)
7379 it->base_level_stop = BEGV; 7411 {
7380 start_from = max (it->base_level_stop, IT_CHARPOS (*it) - 1000); 7412 /* If we lost track of base_level_stop, we need to find
7381 handle_stop_backwards (it, start_from); 7413 prev_stop by looking backwards. This happens, e.g., when
7414 we were reseated to the previous screenful of text by
7415 vertical-motion. */
7416 it->base_level_stop = BEGV;
7417 compute_stop_pos_backwards (it);
7418 handle_stop_backwards (it, it->prev_stop);
7419 }
7420 else
7421 handle_stop_backwards (it, it->base_level_stop);
7382 return GET_NEXT_DISPLAY_ELEMENT (it); 7422 return GET_NEXT_DISPLAY_ELEMENT (it);
7383 } 7423 }
7384 else 7424 else