Fix option g:latex_toc_fold_levels

This commit is contained in:
Karl Yngve Lervåg 2014-07-20 15:59:20 +02:00
parent fa66acf7fd
commit 910db68b44
2 changed files with 8 additions and 8 deletions

View File

@ -260,7 +260,7 @@ function! s:init_options() " {{{1
call latex#util#set_default('g:latex_toc_resize', 1) call latex#util#set_default('g:latex_toc_resize', 1)
call latex#util#set_default('g:latex_toc_hide_help', 0) call latex#util#set_default('g:latex_toc_hide_help', 0)
call latex#util#set_default('g:latex_toc_fold', 0) call latex#util#set_default('g:latex_toc_fold', 0)
call latex#util#set_default('g:latex_toc_fold_levels', 0) call latex#util#set_default('g:latex_toc_fold_levels', 10)
call latex#util#set_default('g:latex_viewer', 'xdg-open') call latex#util#set_default('g:latex_viewer', 'xdg-open')
endfunction endfunction
" }}}1 " }}}1

View File

@ -2,21 +2,21 @@ function! toc#fold_level(lnum) " {{{1
let pline = getline(a:lnum - 1) let pline = getline(a:lnum - 1)
let cline = getline(a:lnum) let cline = getline(a:lnum)
let nline = getline(a:lnum + 1) let nline = getline(a:lnum + 1)
let pn = matchstr(pline, '\d$') let l:pn = matchstr(pline, '\d$')
let cn = matchstr(cline, '\d$') let l:cn = matchstr(cline, '\d$')
let nn = matchstr(nline, '\d$') let l:nn = matchstr(nline, '\d$')
" Don't fold options " Don't fold options
if cline =~# '^\s*$' if cline =~# '^\s*$'
return 0 return 0
endif endif
if nn > cn if l:nn > l:cn && g:latex_toc_fold_levels >= l:nn
return '>' . nn return '>' . l:nn
endif endif
if cn < pn && cn >= nn if l:cn < l:pn && l:cn >= l:nn && g:latex_toc_fold_levels >= l:cn
return cn return l:cn
endif endif
return '=' return '='