aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/screen.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-04-14 22:34:58 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-04-23 00:03:47 -0400
commit07a182c6b57e13e2563aef667131b976db8711cc (patch)
treeef6c3f8a6840aca6905e3f1de8c187749b486652 /src/nvim/screen.c
parenteada8f5aaae0c072571c87b6dbd3c7992541d698 (diff)
downloadrneovim-07a182c6b57e13e2563aef667131b976db8711cc.tar.gz
rneovim-07a182c6b57e13e2563aef667131b976db8711cc.tar.bz2
rneovim-07a182c6b57e13e2563aef667131b976db8711cc.zip
vim-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. https://github.com/vim/vim/commit/06f1ed2f78c5c03af95054fc3a8665df39dec362
Diffstat (limited to 'src/nvim/screen.c')
-rw-r--r--src/nvim/screen.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index b4ebf2ece5..8a51a0a21e 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -1135,6 +1135,8 @@ static void win_update(win_T *wp)
/* reset got_int, otherwise regexp won't work */
save_got_int = got_int;
got_int = 0;
+ // Set the time limit to 'redrawtime'.
+ proftime_T syntax_tm = profile_setlimit(p_rdt);
win_foldinfo.fi_level = 0;
/*
@@ -1362,7 +1364,7 @@ static void win_update(win_T *wp)
/*
* Display one line.
*/
- row = win_line(wp, lnum, srow, wp->w_grid.Rows, mod_top == 0, false);
+ row = win_line(wp, lnum, srow, wp->w_grid.Rows, mod_top == 0, false, &syntax_tm);
wp->w_lines[idx].wl_folded = FALSE;
wp->w_lines[idx].wl_lastlnum = lnum;
@@ -1393,7 +1395,7 @@ static void win_update(win_T *wp)
if (fold_count != 0) {
fold_line(wp, fold_count, &win_foldinfo, lnum, row);
} else {
- (void)win_line(wp, lnum, srow, wp->w_grid.Rows, true, true);
+ (void)win_line(wp, lnum, srow, wp->w_grid.Rows, true, true, &syntax_tm);
}
}
@@ -2041,7 +2043,8 @@ win_line (
int startrow,
int endrow,
bool nochange, // not updating for changed text
- bool number_only // only update the number column
+ bool number_only, // only update the number column
+ proftime_T *syntax_tm
)
{
int c = 0; // init for GCC
@@ -2189,18 +2192,20 @@ win_line (
// To speed up the loop below, set extra_check when there is linebreak,
// trailing white space and/or syntax processing to be done.
extra_check = wp->w_p_lbr;
- if (syntax_present(wp) && !wp->w_s->b_syn_error) {
+ if (syntax_present(wp) && !wp->w_s->b_syn_error && !wp->w_s->b_syn_slow) {
// Prepare for syntax highlighting in this line. When there is an
// error, stop syntax highlighting.
save_did_emsg = did_emsg;
did_emsg = false;
- syntax_start(wp, lnum);
+ syntax_start(wp, lnum, syntax_tm);
if (did_emsg) {
wp->w_s->b_syn_error = true;
} else {
did_emsg = save_did_emsg;
- has_syntax = true;
- extra_check = true;
+ if (!wp->w_s->b_syn_slow) {
+ has_syntax = true;
+ extra_check = true;
+ }
}
}
@@ -2540,8 +2545,9 @@ win_line (
wp->w_cursor = pos;
/* Need to restart syntax highlighting for this line. */
- if (has_syntax)
- syntax_start(wp, lnum);
+ if (has_syntax) {
+ syntax_start(wp, lnum, syntax_tm);
+ }
}
}
@@ -2587,6 +2593,9 @@ win_line (
}
next_search_hl(wp, shl, lnum, (colnr_T)v,
shl == &search_hl ? NULL : cur);
+ if (wp->w_s->b_syn_slow) {
+ has_syntax = false;
+ }
// Need to get the line again, a multi-line regexp may have made it
// invalid.