Skip to content

Commit f58ba25

Browse files
committed
Fix: Detect fold text for indented sections
See vim-latex#129
1 parent 5d5e277 commit f58ba25

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

ftplugin/latex-suite/folding.vim

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,7 @@ function! TexFoldTextFunction()
457457
if getline(v:foldstart) =~ '^\s*' . section_pattern
458458
" This is a section. Search for the content of the mandatory argument {...}
459459
let type = matchstr(getline(v:foldstart), '^\s*\zs' . section_pattern)
460-
let idx = match(getline(v:foldstart), '^\s*' . section_pattern . '\zs')
461-
462-
return myfoldtext . type . ParseSectionTitle(v:foldstart, idx)
460+
return myfoldtext . type . s:ParseSectionTitle(v:foldstart, section_pattern)
463461
else
464462
" This is something.
465463
return myfoldtext . getline(v:foldstart)
@@ -469,12 +467,13 @@ endfunction
469467
" s:ParseSectionTitle: create fold text for sections {{{
470468
" Search for the mandatory argument of the \section command and ignore the
471469
" optional argument.
472-
function! ParseSectionTitle(foldstart, idx)
470+
function! s:ParseSectionTitle(foldstart, section_pattern)
473471
let currlinenr = a:foldstart
474472
let currline = s:StripLine(getline(currlinenr))
475473
let currlinelen = strlen(currline)
476474

477-
let index = a:idx
475+
" Look for the section title after the section macro
476+
let index = match(currline, '^\s*' . a:section_pattern . '\zs')
478477

479478
let maxlines = 10
480479

@@ -491,7 +490,7 @@ function! ParseSectionTitle(foldstart, idx)
491490
" Read a new line.
492491
let maxlines = maxlines - 1
493492
if maxlines < 0
494-
return string . ' Scanned to many lines'
493+
return string . ' Scanned too many lines'
495494
endif
496495
let currlinenr = currlinenr + 1
497496
let currline = s:StripLine(getline(currlinenr))

0 commit comments

Comments
 (0)