Fixed folding of TOC window (fixes #34)

This commit is contained in:
Karl Yngve Lervåg 2014-07-20 15:51:13 +02:00
parent e171ba5a3b
commit fa66acf7fd

View File

@ -1,37 +1,29 @@
function! toc#fold_level(lnum) " {{{1 function! toc#fold_level(lnum) " {{{1
let line = getline(a:lnum) let pline = getline(a:lnum - 1)
let match_s1 = line =~# '^\w\+\s' let cline = getline(a:lnum)
let match_s2 = line =~# '^\w\+\.\w\+\s' let nline = getline(a:lnum + 1)
let match_s3 = line =~# '^\w\+\.\w\+\.\w\+\s' let pn = matchstr(pline, '\d$')
let cn = matchstr(cline, '\d$')
let nn = matchstr(nline, '\d$')
if g:latex_toc_fold_levels >= 3 " Don't fold options
if match_s3 if cline =~# '^\s*$'
return ">3" return 0
endif endif
endif
if g:latex_toc_fold_levels >= 2 if nn > cn
if match_s2 return '>' . nn
return ">2" endif
endif
endif
if match_s1 if cn < pn && cn >= nn
return ">1" return cn
endif endif
" Don't fold options return '='
if line =~# '^\s*$'
return 0
endif
" Return previous fold level
return "="
endfunction endfunction
function! toc#fold_text() " {{{1 function! toc#fold_text() " {{{1
let parts = matchlist(getline(v:foldstart), '^\(.*\)\t\(.*\)$') return getline(v:foldstart)
return printf('%-8s%-72s', parts[1], parts[2])
endfunction endfunction
" }}}1 " }}}1