mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.0.0647: syntax highlighting can make cause a freeze
Problem: Syntax highlighting can make cause a freeze. Solution: Apply 'redrawtime' to syntax highlighting, per window.
This commit is contained in:
37
src/syntax.c
37
src/syntax.c
@@ -367,6 +367,9 @@ static reg_extmatch_T *next_match_extmatch = NULL;
|
||||
static win_T *syn_win; /* current window for highlighting */
|
||||
static buf_T *syn_buf; /* current buffer for highlighting */
|
||||
static synblock_T *syn_block; /* current buffer for highlighting */
|
||||
#ifdef FEAT_RELTIME
|
||||
static proftime_T *syn_tm;
|
||||
#endif
|
||||
static linenr_T current_lnum = 0; /* lnum of current state */
|
||||
static colnr_T current_col = 0; /* column of current state */
|
||||
static int current_state_stored = 0; /* TRUE if stored current state
|
||||
@@ -494,7 +497,7 @@ static void syn_incl_toplevel(int id, int *flagsp);
|
||||
* window.
|
||||
*/
|
||||
void
|
||||
syntax_start(win_T *wp, linenr_T lnum)
|
||||
syntax_start(win_T *wp, linenr_T lnum, proftime_T *syntax_tm UNUSED)
|
||||
{
|
||||
synstate_T *p;
|
||||
synstate_T *last_valid = NULL;
|
||||
@@ -524,6 +527,9 @@ syntax_start(win_T *wp, linenr_T lnum)
|
||||
}
|
||||
changedtick = CHANGEDTICK(syn_buf);
|
||||
syn_win = wp;
|
||||
#ifdef FEAT_RELTIME
|
||||
syn_tm = syntax_tm;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Allocate syntax stack when needed.
|
||||
@@ -3295,6 +3301,9 @@ syn_regexec(
|
||||
syn_time_T *st UNUSED)
|
||||
{
|
||||
int r;
|
||||
#ifdef FEAT_RELTIME
|
||||
int timed_out = FALSE;
|
||||
#endif
|
||||
#ifdef FEAT_PROFILE
|
||||
proftime_T pt;
|
||||
|
||||
@@ -3303,7 +3312,13 @@ syn_regexec(
|
||||
#endif
|
||||
|
||||
rmp->rmm_maxcol = syn_buf->b_p_smc;
|
||||
r = vim_regexec_multi(rmp, syn_win, syn_buf, lnum, col, NULL, NULL);
|
||||
r = vim_regexec_multi(rmp, syn_win, syn_buf, lnum, col,
|
||||
#ifdef FEAT_RELTIME
|
||||
syn_tm, &timed_out
|
||||
#else
|
||||
NULL, NULL
|
||||
#endif
|
||||
);
|
||||
|
||||
#ifdef FEAT_PROFILE
|
||||
if (syn_time_on)
|
||||
@@ -3317,6 +3332,10 @@ syn_regexec(
|
||||
++st->match;
|
||||
}
|
||||
#endif
|
||||
#ifdef FEAT_RELTIME
|
||||
if (timed_out)
|
||||
syn_win->w_s->b_syn_slow = TRUE;
|
||||
#endif
|
||||
|
||||
if (r > 0)
|
||||
{
|
||||
@@ -3575,6 +3594,9 @@ syntax_clear(synblock_T *block)
|
||||
int i;
|
||||
|
||||
block->b_syn_error = FALSE; /* clear previous error */
|
||||
#ifdef FEAT_RELTIME
|
||||
block->b_syn_slow = FALSE; /* clear previous timeout */
|
||||
#endif
|
||||
block->b_syn_ic = FALSE; /* Use case, by default */
|
||||
block->b_syn_spell = SYNSPL_DEFAULT; /* default spell checking */
|
||||
block->b_syn_containedin = FALSE;
|
||||
@@ -6542,7 +6564,7 @@ syn_get_id(
|
||||
if (wp->w_buffer != syn_buf
|
||||
|| lnum != current_lnum
|
||||
|| col < current_col)
|
||||
syntax_start(wp, lnum);
|
||||
syntax_start(wp, lnum, NULL);
|
||||
else if (wp->w_buffer == syn_buf
|
||||
&& lnum == current_lnum
|
||||
&& col > current_col)
|
||||
@@ -6611,9 +6633,14 @@ syn_get_foldlevel(win_T *wp, long lnum)
|
||||
int i;
|
||||
|
||||
/* Return quickly when there are no fold items at all. */
|
||||
if (wp->w_s->b_syn_folditems != 0)
|
||||
if (wp->w_s->b_syn_folditems != 0
|
||||
&& !wp->w_s->b_syn_error
|
||||
# ifdef SYN_TIME_LIMIT
|
||||
&& !wp->w_s->b_syn_slow
|
||||
# endif
|
||||
)
|
||||
{
|
||||
syntax_start(wp, lnum);
|
||||
syntax_start(wp, lnum, NULL);
|
||||
|
||||
for (i = 0; i < current_state.ga_len; ++i)
|
||||
if (CUR_STATE(i).si_flags & HL_FOLD)
|
||||
|
Reference in New Issue
Block a user