aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory Heytings2022-07-18 10:08:33 +0000
committerGregory Heytings2022-07-18 12:11:08 +0200
commitcc7f37b2a41afe2dccd015de2b2a70e20c6e323f (patch)
tree9a3d3bb98be90b3f2c9bca2b92c8b9fcc1a06f59
parent66704fbbcf662666dbf0351fe7ae8b3bf2fbb3ca (diff)
downloademacs-cc7f37b2a41afe2dccd015de2b2a70e20c6e323f.tar.gz
emacs-cc7f37b2a41afe2dccd015de2b2a70e20c6e323f.zip
Further improvements to long lines handling.
* src/xdisp.c (get_visually_first_element): Fix segfault. (get_narrowed_begv): Specific improvement for character-only terminals.
-rw-r--r--src/xdisp.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 98bf15a8594..d69d7440bc0 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -3501,9 +3501,12 @@ init_iterator (struct it *it, struct window *w,
3501ptrdiff_t 3501ptrdiff_t
3502get_narrowed_begv (struct window *w) 3502get_narrowed_begv (struct window *w)
3503{ 3503{
3504 int len; ptrdiff_t begv; 3504 int len, fact; ptrdiff_t begv;
3505 len = 3 * (window_body_width (w, WINDOW_BODY_IN_CANONICAL_CHARS) * 3505 /* In a character-only terminal, only one font size is used, so we
3506 window_body_height (w, WINDOW_BODY_IN_CANONICAL_CHARS)); 3506 can use a smaller factor. */
3507 fact = EQ (Fterminal_live_p (Qnil), Qt) ? 2 : 3;
3508 len = fact * (window_body_width (w, WINDOW_BODY_IN_CANONICAL_CHARS) *
3509 window_body_height (w, WINDOW_BODY_IN_CANONICAL_CHARS));
3507 begv = max ((window_point (w) / len - 1) * len, BEGV); 3510 begv = max ((window_point (w) / len - 1) * len, BEGV);
3508 return begv == BEGV ? 0 : begv; 3511 return begv == BEGV ? 0 : begv;
3509} 3512}
@@ -8668,6 +8671,16 @@ get_visually_first_element (struct it *it)
8668 8671
8669 SET_WITH_NARROWED_BEGV (it, bob, string_p ? 0 : BEGV); 8672 SET_WITH_NARROWED_BEGV (it, bob, string_p ? 0 : BEGV);
8670 8673
8674 /* Reseat again when, as a consequence of the SET_WITH_NARROWED_BEGV
8675 above, the iterator is before bob. */
8676 if (!string_p && IT_CHARPOS (*it) < bob)
8677 {
8678 struct text_pos pos;
8679 pos.charpos = bob;
8680 pos.bytepos = CHAR_TO_BYTE (bob);
8681 reseat (it, pos, true);
8682 }
8683
8671 if (STRINGP (it->string)) 8684 if (STRINGP (it->string))
8672 { 8685 {
8673 it->bidi_it.charpos = IT_STRING_CHARPOS (*it); 8686 it->bidi_it.charpos = IT_STRING_CHARPOS (*it);