mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -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:
@@ -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
|
||||
|
Reference in New Issue
Block a user