summaryrefslogtreecommitdiff
path: root/src/testdir/test_syntax.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-06-18 22:41:03 +0200
committerBram Moolenaar <Bram@vim.org>2017-06-18 22:41:03 +0200
commit06f1ed2f78c5c03af95054fc3a8665df39dec362 (patch)
tree413bd7310eafa3df68daf706d304ce4ae452b311 /src/testdir/test_syntax.vim
parent0946326580e6f034fe2c88d041407ea0fde980ab (diff)
downloadvim-06f1ed2f78c5c03af95054fc3a8665df39dec362.zip
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.
Diffstat (limited to 'src/testdir/test_syntax.vim')
-rw-r--r--src/testdir/test_syntax.vim34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/testdir/test_syntax.vim b/src/testdir/test_syntax.vim
index eb093c8ff..427ed7b4f 100644
--- a/src/testdir/test_syntax.vim
+++ b/src/testdir/test_syntax.vim
@@ -424,3 +424,37 @@ func Test_bg_detection()
hi Normal ctermbg=12
call assert_equal('dark', &bg)
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