aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2022-10-27 15:24:53 +0300
committerEli Zaretskii2022-10-27 15:24:53 +0300
commit93fb14d0c805f492f0107c5ddd2914cde6d219b5 (patch)
tree023c90b3a32ca9177024d62da7729a959939cda7 /src
parentaf46d8a7ecb5c8c0016cc8dc88fa59ef244a0ced (diff)
downloademacs-93fb14d0c805f492f0107c5ddd2914cde6d219b5.tar.gz
emacs-93fb14d0c805f492f0107c5ddd2914cde6d219b5.zip
Avoid recentering when point enters invisible text at BOL
* src/xdisp.c (try_cursor_movement): Don't say we must scroll when point is inside invisible text at beginning of a glyph row. (Bug#58793)
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 557cb606317..32675cd76ac 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -18926,7 +18926,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp,
18926 while (MATRIX_ROW_BOTTOM_Y (row) < last_y 18926 while (MATRIX_ROW_BOTTOM_Y (row) < last_y
18927 && MATRIX_ROW_END_CHARPOS (row) == PT 18927 && MATRIX_ROW_END_CHARPOS (row) == PT
18928 && row < MATRIX_MODE_LINE_ROW (w->current_matrix) 18928 && row < MATRIX_MODE_LINE_ROW (w->current_matrix)
18929 && MATRIX_ROW_START_CHARPOS (row+1) == PT 18929 && MATRIX_ROW_START_CHARPOS (row+1) >= PT
18930 && !cursor_row_p (row)) 18930 && !cursor_row_p (row))
18931 ++row; 18931 ++row;
18932 18932
@@ -19023,7 +19023,12 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp,
19023 rc = CURSOR_MOVEMENT_SUCCESS; 19023 rc = CURSOR_MOVEMENT_SUCCESS;
19024 } 19024 }
19025 19025
19026 if (PT < MATRIX_ROW_START_CHARPOS (row) 19026 if ((PT < MATRIX_ROW_START_CHARPOS (row)
19027 && (row == MATRIX_FIRST_TEXT_ROW (w->current_matrix)
19028 /* Don't give up if point is inside invisible text
19029 at the beginning of its glyph row. */
19030 || (MATRIX_ROW_END_CHARPOS (row-1)
19031 == MATRIX_ROW_START_CHARPOS (row))))
19027 || PT > MATRIX_ROW_END_CHARPOS (row)) 19032 || PT > MATRIX_ROW_END_CHARPOS (row))
19028 { 19033 {
19029 /* if PT is not in the glyph row, give up. */ 19034 /* if PT is not in the glyph row, give up. */
@@ -19105,12 +19110,23 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp,
19105 continuation lines' rows is implemented for 19110 continuation lines' rows is implemented for
19106 bidi-reordered rows. */ 19111 bidi-reordered rows. */
19107 bool rv = false; 19112 bool rv = false;
19113 bool pt_invis = false;
19114 Lisp_Object val = get_char_property_and_overlay (make_fixnum (PT),
19115 Qinvisible,
19116 Qnil, NULL);
19117
19118 if (TEXT_PROP_MEANS_INVISIBLE (val) != 0)
19119 pt_invis = true;
19108 19120
19109 do 19121 do
19110 { 19122 {
19111 bool at_zv_p = false, exact_match_p = false; 19123 bool at_zv_p = false, exact_match_p = false;
19112 19124
19113 if (MATRIX_ROW_START_CHARPOS (row) <= PT 19125 /* If point is in invisible text, we cannot assume
19126 it must be after row's start position, since the
19127 row could have invisible text at its beginning
19128 where point is located. */
19129 if ((pt_invis || MATRIX_ROW_START_CHARPOS (row) <= PT)
19114 && PT <= MATRIX_ROW_END_CHARPOS (row) 19130 && PT <= MATRIX_ROW_END_CHARPOS (row)
19115 && cursor_row_p (row)) 19131 && cursor_row_p (row))
19116 rv |= set_cursor_from_row (w, row, w->current_matrix, 19132 rv |= set_cursor_from_row (w, row, w->current_matrix,
@@ -19142,16 +19158,8 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp,
19142 invisible text? In that case, we trust 19158 invisible text? In that case, we trust
19143 'set_cursor_from_row' to do its job and 19159 'set_cursor_from_row' to do its job and
19144 find the best position for the cursor. */ 19160 find the best position for the cursor. */
19145 if (!exact_match_p) 19161 if (!exact_match_p && pt_invis)
19146 { 19162 exact_match_p = true;
19147 Lisp_Object val =
19148 get_char_property_and_overlay (make_fixnum (PT),
19149 Qinvisible,
19150 Qnil, NULL);
19151
19152 if (TEXT_PROP_MEANS_INVISIBLE (val) != 0)
19153 exact_match_p = true;
19154 }
19155 } 19163 }
19156 if (at_zv_p || exact_match_p) 19164 if (at_zv_p || exact_match_p)
19157 { 19165 {