From dc2053cd45caeb4e61d461a7d889cee5d55b67d9 Mon Sep 17 00:00:00 2001 From: Gerd Wachsmuth Date: Fri, 30 Mar 2018 09:08:34 +0200 Subject: [PATCH] Try to improve performance of ParseSectionTitle --- ftplugin/latex-suite/folding.vim | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ftplugin/latex-suite/folding.vim b/ftplugin/latex-suite/folding.vim index d689941..bc22016 100644 --- a/ftplugin/latex-suite/folding.vim +++ b/ftplugin/latex-suite/folding.vim @@ -504,7 +504,7 @@ function! s:ParseSectionTitle(foldstart, section_pattern) continue endif - " Look for [] and {} + " Look for [] and {} at current position if currline[index] =~ '[[{]' if(currdepth == 0) && (currline[index] =~ '{') let found_mandatory = 1 @@ -514,11 +514,17 @@ function! s:ParseSectionTitle(foldstart, section_pattern) let currdepth -= 1 endif - if found_mandatory - let string .= currline[index] + " Look for the next interesting character + let next_index = match( currline, '[{}[\]]', index + 1 ) + if next_index == -1 + let next_index = currlinelen + 1 endif - let index = index + 1 + " Update the string + if found_mandatory + let string .= currline[index:next_index-1] + endif + let index = next_index endwhile return string