From: Gregory Heytings Date: Thu, 4 Aug 2022 09:01:55 +0000 (+0000) Subject: Improve Bidi with long lines. X-Git-Tag: emacs-29.0.90~1447^2~431^2~3 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=82b602dc2f52775a4082d24d64380867da051350;p=emacs.git Improve Bidi with long lines. * src/composite.c (composition_compute_stop_pos): Use an 'endpos' that is not too far away. (find_automatic_composition): Use a 'head' that is not too far away. Also make sure that this code path is not taken when long line optimizations are disabled. * src/dispextern.h (struct composition_it): Add a field that points to the parent iterator. * src/xdisp.c (init_iterator): Set it. --- diff --git a/src/composite.c b/src/composite.c index e721fe8c81f..9e641722cac 100644 --- a/src/composite.c +++ b/src/composite.c @@ -1021,7 +1021,11 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos, /* But we don't know where to stop the searching. */ endpos = NILP (string) ? BEGV - 1 : -1; /* Usually we don't reach ENDPOS because we stop searching - at an uncomposable character (NL, LRE, etc). */ + at an uncomposable character (NL, LRE, etc). In buffers + with long lines, however, NL might be far away, so + pretend that the buffer is smaller. */ + if (current_buffer->long_line_optimizations_p) + endpos = get_closer_narrowed_begv (cmp_it->parent_it->w, charpos); } } cmp_it->id = -1; @@ -1580,7 +1584,6 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit, ptrdiff_t backlim, Lisp_Object window; struct window *w; bool need_adjustment = 0; - ptrdiff_t narrowed_begv; window = Fget_buffer_window (Fcurrent_buffer (), Qnil); if (NILP (window)) @@ -1597,11 +1600,14 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit, ptrdiff_t backlim, } else head = backlim; - /* In buffers with very long lines, this function becomes very - slow. Pretend that the buffer is narrowed to make it fast. */ - narrowed_begv = get_narrowed_begv (w, window_point (w)); - if (pos > narrowed_begv) - head = narrowed_begv; + if (current_buffer->long_line_optimizations_p) + { + /* In buffers with very long lines, this function becomes very + slow. Pretend that the buffer is narrowed to make it fast. */ + ptrdiff_t begv = get_closer_narrowed_begv (w, window_point (w)); + if (pos > begv) + head = narrowed_begv; + } tail = ZV; stop = GPT; cur.pos_byte = CHAR_TO_BYTE (cur.pos); diff --git a/src/dispextern.h b/src/dispextern.h index 037e02ff58f..12ba927261f 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -2287,6 +2287,8 @@ struct composition_it reverse order, and thus the grapheme clusters must be rendered from the last to the first. */ bool reversed_p; + /* Parent iterator. */ + struct it *parent_it; /** The following members contain information about the current grapheme cluster. */ diff --git a/src/xdisp.c b/src/xdisp.c index 7d62c7823ed..12f56227e46 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -3229,6 +3229,7 @@ init_iterator (struct it *it, struct window *w, it->f = XFRAME (w->frame); it->cmp_it.id = -1; + it->cmp_it.parent_it = it; if (max_redisplay_ticks > 0) update_redisplay_ticks (0, w);