summaryrefslogtreecommitdiff
path: root/src/composite.c
diff options
context:
space:
mode:
authorGregory Heytings <gregory@heytings.org>2022-08-04 09:01:55 +0000
committerGregory Heytings <gregory@heytings.org>2022-08-04 11:07:28 +0200
commit82b602dc2f52775a4082d24d64380867da051350 (patch)
treeb18e661a9a0011c25552aa4ff748de731a1790d7 /src/composite.c
parentc6b5726130e9c3c297747a47c267dad5e8da4f52 (diff)
downloademacs-82b602dc2f52775a4082d24d64380867da051350.tar.gz
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.
Diffstat (limited to 'src/composite.c')
-rw-r--r--src/composite.c20
1 files changed, 13 insertions, 7 deletions
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);