Skip to content

Commit f3d769a

Browse files
committed
patch 8.0.1133: syntax timeout not used correctly
Problem: Syntax timeout not used correctly. Solution: Do not pass the timeout to syntax_start() but set it explicitly. (Yasuhiro Matsumoto, closes #2139)
1 parent 8b21de3 commit f3d769a

4 files changed

Lines changed: 38 additions & 29 deletions

File tree

src/proto/syntax.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* syntax.c */
2-
void syntax_start(win_T *wp, linenr_T lnum, proftime_T *syntax_tm);
2+
void syn_set_timeout(proftime_T *tm);
3+
void syntax_start(win_T *wp, linenr_T lnum);
34
void syn_stack_free_all(synblock_T *block);
45
void syn_stack_apply_changes(buf_T *buf);
56
void syntax_end_parsing(linenr_T lnum);

src/screen.c

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
131131
static void fill_foldcolumn(char_u *p, win_T *wp, int closed, linenr_T lnum);
132132
static void copy_text_attr(int off, char_u *buf, int len, int attr);
133133
#endif
134-
static int win_line(win_T *, linenr_T, int, int, int nochange, proftime_T *syntax_tm);
134+
static int win_line(win_T *, linenr_T, int, int, int nochange);
135135
static int char_needs_redraw(int off_from, int off_to, int cols);
136136
static void draw_vsep_win(win_T *wp, int row);
137137
#ifdef FEAT_STL_OPT
@@ -930,6 +930,7 @@ update_single_line(win_T *wp, linenr_T lnum)
930930
#ifdef SYN_TIME_LIMIT
931931
/* Set the time limit to 'redrawtime'. */
932932
profile_setlimit(p_rdt, &syntax_tm);
933+
syn_set_timeout(&syntax_tm);
933934
#endif
934935
update_prepare();
935936

@@ -944,13 +945,7 @@ update_single_line(win_T *wp, linenr_T lnum)
944945
start_search_hl();
945946
prepare_search_hl(wp, lnum);
946947
# endif
947-
win_line(wp, lnum, row, row + wp->w_lines[j].wl_size, FALSE,
948-
#ifdef SYN_TIME_LIMIT
949-
&syntax_tm
950-
#else
951-
NULL
952-
#endif
953-
);
948+
win_line(wp, lnum, row, row + wp->w_lines[j].wl_size, FALSE);
954949
# if defined(FEAT_SEARCH_EXTRA)
955950
end_search_hl();
956951
# endif
@@ -960,6 +955,10 @@ update_single_line(win_T *wp, linenr_T lnum)
960955
}
961956

962957
update_finish();
958+
959+
#ifdef SYN_TIME_LIMIT
960+
syn_set_timeout(NULL);
961+
#endif
963962
}
964963
need_cursor_line_redraw = FALSE;
965964
}
@@ -1805,6 +1804,7 @@ win_update(win_T *wp)
18051804
#ifdef SYN_TIME_LIMIT
18061805
/* Set the time limit to 'redrawtime'. */
18071806
profile_setlimit(p_rdt, &syntax_tm);
1807+
syn_set_timeout(&syntax_tm);
18081808
#endif
18091809
#ifdef FEAT_FOLDING
18101810
win_foldinfo.fi_level = 0;
@@ -2109,13 +2109,7 @@ win_update(win_T *wp)
21092109
/*
21102110
* Display one line.
21112111
*/
2112-
row = win_line(wp, lnum, srow, wp->w_height, mod_top == 0,
2113-
#ifdef SYN_TIME_LIMIT
2114-
&syntax_tm
2115-
#else
2116-
NULL
2117-
#endif
2118-
);
2112+
row = win_line(wp, lnum, srow, wp->w_height, mod_top == 0);
21192113

21202114
#ifdef FEAT_FOLDING
21212115
wp->w_lines[idx].wl_folded = FALSE;
@@ -2275,6 +2269,10 @@ win_update(win_T *wp)
22752269
win_draw_end(wp, '~', ' ', row, wp->w_height, HLF_EOB);
22762270
}
22772271

2272+
#ifdef SYN_TIME_LIMIT
2273+
syn_set_timeout(NULL);
2274+
#endif
2275+
22782276
/* Reset the type of redrawing required, the window has been updated. */
22792277
wp->w_redr_type = 0;
22802278
#ifdef FEAT_DIFF
@@ -3000,8 +2998,7 @@ win_line(
30002998
linenr_T lnum,
30012999
int startrow,
30023000
int endrow,
3003-
int nochange UNUSED, /* not updating for changed text */
3004-
proftime_T *syntax_tm UNUSED)
3001+
int nochange UNUSED) /* not updating for changed text */
30053002
{
30063003
int col = 0; /* visual column on screen */
30073004
unsigned off; /* offset in ScreenLines/ScreenAttrs */
@@ -3216,7 +3213,7 @@ win_line(
32163213
* error, stop syntax highlighting. */
32173214
save_did_emsg = did_emsg;
32183215
did_emsg = FALSE;
3219-
syntax_start(wp, lnum, syntax_tm);
3216+
syntax_start(wp, lnum);
32203217
if (did_emsg)
32213218
wp->w_s->b_syn_error = TRUE;
32223219
else
@@ -3614,7 +3611,7 @@ win_line(
36143611
# ifdef FEAT_SYN_HL
36153612
/* Need to restart syntax highlighting for this line. */
36163613
if (has_syntax)
3617-
syntax_start(wp, lnum, syntax_tm);
3614+
syntax_start(wp, lnum);
36183615
# endif
36193616
}
36203617
#endif

src/syntax.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static win_T *syn_win; /* current window for highlighting */
368368
static buf_T *syn_buf; /* current buffer for highlighting */
369369
static synblock_T *syn_block; /* current buffer for highlighting */
370370
#ifdef FEAT_RELTIME
371-
static proftime_T *syn_tm;
371+
static proftime_T *syn_tm; /* timeout limit */
372372
#endif
373373
static linenr_T current_lnum = 0; /* lnum of current state */
374374
static colnr_T current_col = 0; /* column of current state */
@@ -489,6 +489,18 @@ static int get_id_list(char_u **arg, int keylen, short **list, int skip);
489489
static void syn_combine_list(short **clstr1, short **clstr2, int list_op);
490490
static void syn_incl_toplevel(int id, int *flagsp);
491491

492+
#if defined(FEAT_RELTIME) || defined(PROTO)
493+
/*
494+
* Set the timeout used for syntax highlighting.
495+
* Use NULL to reset, no timeout.
496+
*/
497+
void
498+
syn_set_timeout(proftime_T *tm)
499+
{
500+
syn_tm = tm;
501+
}
502+
#endif
503+
492504
/*
493505
* Start the syntax recognition for a line. This function is normally called
494506
* from the screen updating, once for each displayed line.
@@ -497,7 +509,7 @@ static void syn_incl_toplevel(int id, int *flagsp);
497509
* window.
498510
*/
499511
void
500-
syntax_start(win_T *wp, linenr_T lnum, proftime_T *syntax_tm UNUSED)
512+
syntax_start(win_T *wp, linenr_T lnum)
501513
{
502514
synstate_T *p;
503515
synstate_T *last_valid = NULL;
@@ -527,9 +539,6 @@ syntax_start(win_T *wp, linenr_T lnum, proftime_T *syntax_tm UNUSED)
527539
}
528540
changedtick = CHANGEDTICK(syn_buf);
529541
syn_win = wp;
530-
#ifdef FEAT_RELTIME
531-
syn_tm = syntax_tm;
532-
#endif
533542

534543
/*
535544
* Allocate syntax stack when needed.
@@ -6569,7 +6578,7 @@ syn_get_id(
65696578
if (wp->w_buffer != syn_buf
65706579
|| lnum != current_lnum
65716580
|| col < current_col)
6572-
syntax_start(wp, lnum, NULL);
6581+
syntax_start(wp, lnum);
65736582
else if (wp->w_buffer == syn_buf
65746583
&& lnum == current_lnum
65756584
&& col > current_col)
@@ -6645,7 +6654,7 @@ syn_get_foldlevel(win_T *wp, long lnum)
66456654
# endif
66466655
)
66476656
{
6648-
syntax_start(wp, lnum, NULL);
6657+
syntax_start(wp, lnum);
66496658

66506659
for (i = 0; i < current_state.ga_len; ++i)
66516660
if (CUR_STATE(i).si_flags & HL_FOLD)
@@ -7006,7 +7015,7 @@ static char *(highlight_init_light[]) = {
70067015
CENT("ToolbarLine term=underline ctermbg=LightGrey",
70077016
"ToolbarLine term=underline ctermbg=LightGrey guibg=LightGrey"),
70087017
CENT("ToolbarButton cterm=bold ctermfg=White ctermbg=DarkGrey",
7009-
"ToolbarButton cterm=bold ctermfg=White ctermbg=DarkGrey gui=bold guifg=White guibg=DarkGrey"),
7018+
"ToolbarButton cterm=bold ctermfg=White ctermbg=DarkGrey gui=bold guifg=White guibg=Grey40"),
70107019
#endif
70117020
NULL
70127021
};
@@ -7102,7 +7111,7 @@ static char *(highlight_init_dark[]) = {
71027111
#endif
71037112
#ifdef FEAT_MENU
71047113
CENT("ToolbarLine term=underline ctermbg=DarkGrey",
7105-
"ToolbarLine term=underline ctermbg=DarkGrey guibg=DarkGrey"),
7114+
"ToolbarLine term=underline ctermbg=DarkGrey guibg=Grey50"),
71067115
CENT("ToolbarButton cterm=bold ctermfg=Black ctermbg=LightGrey",
71077116
"ToolbarButton cterm=bold ctermfg=Black ctermbg=LightGrey gui=bold guifg=Black guibg=LightGrey"),
71087117
#endif

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1133,
764766
/**/
765767
1132,
766768
/**/

0 commit comments

Comments
 (0)