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