@@ -457,9 +457,7 @@ function! TexFoldTextFunction()
457
457
if getline (v: foldstart ) = ~ ' ^\s*' . section_pattern
458
458
" This is a section. Search for the content of the mandatory argument {...}
459
459
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)
463
461
else
464
462
" This is something.
465
463
return myfoldtext . getline (v: foldstart )
@@ -469,12 +467,13 @@ endfunction
469
467
" s:ParseSectionTitle: create fold text for sections {{{
470
468
" Search for the mandatory argument of the \section command and ignore the
471
469
" optional argument.
472
- function ! ParseSectionTitle (foldstart, idx )
470
+ function ! s: ParseSectionTitle (foldstart, section_pattern )
473
471
let currlinenr = a: foldstart
474
472
let currline = s: StripLine (getline (currlinenr))
475
473
let currlinelen = strlen (currline)
476
474
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' )
478
477
479
478
let maxlines = 10
480
479
@@ -491,7 +490,7 @@ function! ParseSectionTitle(foldstart, idx)
491
490
" Read a new line.
492
491
let maxlines = maxlines - 1
493
492
if maxlines < 0
494
- return string . ' Scanned to many lines'
493
+ return string . ' Scanned too many lines'
495
494
endif
496
495
let currlinenr = currlinenr + 1
497
496
let currline = s: StripLine (getline (currlinenr))
0 commit comments