From 1ee9275c1bb3fe7754188931d38c5b4404d5419f Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 13 Jan 2022 15:40:30 +0200 Subject: [PATCH] Avoid scrolling display when point moves into invisible text * src/xdisp.c (try_cursor_movement): Handle point moving into invisible text. (Bug#53215) --- src/xdisp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/xdisp.c b/src/xdisp.c index 2326df4300d..977d31703fb 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -18557,6 +18557,20 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, || (NILP (g->object) && (g->charpos == PT || (g->charpos == 0 && endpos - 1 == PT))); + /* Perhaps the point position is inside + invisible text? In that case, we trust + 'set_cursor_from_row' to do its job and + find the best position for the cursor. */ + if (!exact_match_p) + { + Lisp_Object val = + get_char_property_and_overlay (make_fixnum (PT), + Qinvisible, + Qnil, NULL); + + if (TEXT_PROP_MEANS_INVISIBLE (val) != 0) + exact_match_p = true; + } } if (at_zv_p || exact_match_p) { -- 2.39.2