From: Eli Zaretskii Date: Fri, 17 Jun 2022 15:24:33 +0000 (+0300) Subject: Handle too long syntactic fontifications X-Git-Tag: emacs-29.0.90~1447^2~1506^2~6 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=94672c2936dd58a1837fd208f8678074ca8193c3;p=emacs.git Handle too long syntactic fontifications * src/syntax.c (scan_sexps_forward): Call 'update_redisplay_ticks' after finishing the loop. * src/dispnew.c (make_current): Make sure enabled rows of the current matrix have a valid hash, even if redisplay of a window was aborted due to slowness. This avoids assertion violations in 'scrolling_window' due to the wrong hash value. --- diff --git a/src/dispnew.c b/src/dispnew.c index 7a4d9f8710b..9d587ea00e3 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -2738,6 +2738,14 @@ make_current (struct glyph_matrix *desired_matrix, struct glyph_matrix *current_ struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, row); bool mouse_face_p = current_row->mouse_face_p; + /* If we aborted redisplay of this window, a row in the desired + matrix might not have its hash computed. */ + if (!(!desired_row->used[0] + && !desired_row->used[1] + && !desired_row->used[2]) + && !desired_row->hash) + desired_row->hash = row_hash (desired_row); + /* Do current_row = desired_row. This exchanges glyph pointers between both rows, and does a structure assignment otherwise. */ assign_row (current_row, desired_row); diff --git a/src/syntax.c b/src/syntax.c index f9022d18d26..de9193e2deb 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -20,6 +20,7 @@ along with GNU Emacs. If not, see . */ #include #include "lisp.h" +#include "dispextern.h" #include "character.h" #include "buffer.h" #include "regex-emacs.h" @@ -3195,6 +3196,7 @@ scan_sexps_forward (struct lisp_parse_state *state, ptrdiff_t out_bytepos, out_charpos; int temp; unsigned short int quit_count = 0; + ptrdiff_t started_from = from; prev_from = from; prev_from_byte = from_byte; @@ -3474,6 +3476,12 @@ do { prev_from = from; \ state->levelstarts); state->prev_syntax = (SYNTAX_FLAGS_COMSTARTEND_FIRST (prev_from_syntax) || state->quoted) ? prev_from_syntax : Smax; + + /* The factor of 10 below is a heuristic that needs to be tuned. It + means we consider 10 buffer positions examined by this function + roughly equivalent to the display engine iterating over a single + buffer position. */ + update_redisplay_ticks ((from - started_from) / 10 + 1, NULL); } /* Convert a (lisp) parse state to the internal form used in