aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
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/testdir
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/testdir')
-rw-r--r--src/nvim/testdir/test_syntax.vim34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim
index 6978faeb7b..850947f89f 100644
--- a/src/nvim/testdir/test_syntax.vim
+++ b/src/nvim/testdir/test_syntax.vim
@@ -503,3 +503,37 @@ func Test_syn_wrong_z_one()
" call test_override("ALL", 0)
bwipe!
endfunc
+
+func Test_syntax_hangs()
+ if !has('reltime') || !has('float') || !has('syntax')
+ return
+ endif
+
+ " This pattern takes a long time to match, it should timeout.
+ new
+ call setline(1, ['aaa', repeat('abc ', 1000), 'ccc'])
+ let start = reltime()
+ set nolazyredraw redrawtime=101
+ syn match Error /\%#=1a*.*X\@<=b*/
+ redraw
+ let elapsed = reltimefloat(reltime(start))
+ call assert_true(elapsed > 0.1)
+ call assert_true(elapsed < 1.0)
+
+ " second time syntax HL is disabled
+ let start = reltime()
+ redraw
+ let elapsed = reltimefloat(reltime(start))
+ call assert_true(elapsed < 0.1)
+
+ " after CTRL-L the timeout flag is reset
+ let start = reltime()
+ exe "normal \<C-L>"
+ redraw
+ let elapsed = reltimefloat(reltime(start))
+ call assert_true(elapsed > 0.1)
+ call assert_true(elapsed < 1.0)
+
+ set redrawtime&
+ bwipe!
+endfunc