Fixed #446: Optimized tikz indentation

This commit is contained in:
Karl Yngve Lervåg 2016-04-28 23:27:34 +02:00
parent 7bf1731cde
commit b514c42cee
2 changed files with 3 additions and 28 deletions

View File

@ -131,29 +131,8 @@ endfunction
" }}}1
function! vimtex#env#is_inside(env) " {{{1
let l:pos = getpos('.')
let l:pos_val = 10000*l:pos[1] + l:pos[2]
let l:tries = 10
while l:tries > 0
let l:tries -= 1
let [l:open, l:close] = vimtex#delim#get_surrounding('env')
if empty(l:open) | break | endif
if !empty(l:close) && (l:pos_val >= 10000*l:close.lnum + l:close.cnum)
continue
endif
if l:open.name ==# a:env
call setpos('.', l:pos)
return 1
endif
call setpos('.', s:pos_prev(l:open))
endwhile
call setpos('.', l:pos)
return 0
return searchpairpos('\\begin\s*{' . a:env . '\*\?}', '',
\ '\\end\s*{' . a:env . '\*\?}', 'bnWm')
endfunction
" }}}1

View File

@ -113,11 +113,7 @@ endfunction
" }}}1
function! s:indent_tikz(lnum, prev) " {{{1
let l:winview = winsaveview()
let l:inside_tikzpicture = vimtex#env#is_inside('tikzpicture')
call winrestview(l:winview)
if l:inside_tikzpicture
if vimtex#env#is_inside('tikzpicture')
let l:prev_starts = a:prev =~# s:tikz_commands
let l:prev_stops = a:prev =~# ';\s*$'