emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 94672c2936 07/14: Handle too long syntactic fontifications


From: Eli Zaretskii
Subject: master 94672c2936 07/14: Handle too long syntactic fontifications
Date: Fri, 24 Jun 2022 03:54:18 -0400 (EDT)

branch: master
commit 94672c2936dd58a1837fd208f8678074ca8193c3
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    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.
---
 src/dispnew.c | 8 ++++++++
 src/syntax.c  | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/src/dispnew.c b/src/dispnew.c
index 7a4d9f8710..9d587ea00e 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 f9022d18d2..de9193e2de 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -20,6 +20,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include <config.h>
 
 #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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]