Improve speed of s:is_verbatim

This commit is contained in:
Karl Yngve Lervåg 2017-01-10 23:15:41 +01:00
parent 3e63a12448
commit a070901fb2
2 changed files with 4 additions and 4 deletions

View File

@ -118,8 +118,9 @@ endfunction
" }}}1
function! vimtex#env#is_inside(env) " {{{1
let l:stopline = max([line('.') - 50, 1])
return searchpair('\\begin\s*{' . a:env . '\*\?}', '',
\ '\\end\s*{' . a:env . '\*\?}', 'bnW')
\ '\\end\s*{' . a:env . '\*\?}', 'bnW', 0, l:stopline)
endfunction
" }}}1

View File

@ -80,9 +80,8 @@ endfunction
" }}}1
function! s:is_verbatim(line, lnum) " {{{1
let l:env = a:line !~# '\v\\%(begin|end)\{%(verbatim|lstlisting|minted)'
let l:syn = synIDattr(synID(a:lnum, 1, 1), 'name') ==# 'texZone'
return l:env && l:syn
return a:line !~# '\v\\%(begin|end)\{%(verbatim|lstlisting|minted)'
\ && vimtex#env#is_inside('\%(lstlisting\|verbatim\|minted\)')
endfunction
" }}}1