Skip to content

Commit 30dcd52

Browse files
committed
Move substitute out of the loop to decrease lag
1 parent f140fa6 commit 30dcd52

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

after/syntax/nerdtree.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ if exists('g:NERDTreeLimitedSyntax') && !exists('g:NERDTreeSyntaxDisableDefaultE
383383
endif
384384

385385
let s:characters = '[a-zA-Z0-9_\#\-\+\*\%\!\~\(\)\{\}\&\.\$\@]'
386+
" substitute will 'eat' single backlashes on the string
387+
let s:chars_double_lashes = substitute(s:characters, '\\', '\\\\', 'g')
386388

387389
" Extension colors
388390

@@ -485,9 +487,7 @@ for [key, val] in items(g:NERDTreePatternMatchHighlightColor)
485487
let suffix = substitute(key, '\W', '', 'g')
486488
let label_identifier = 'nerdtreePatternMatchLabel_'.suffix
487489
let icon_identifier = 'nerdtreePatternMatchIcon_'.suffix
488-
" substitute will 'eat' single backlashes on the string
489-
let chars_double_lashes = substitute(s:characters, '\\', '\\\\', 'g')
490-
let sub_regexp = substitute(key, '\v\\@<!\.', chars_double_lashes, 'g')
490+
let sub_regexp = substitute(key, '\v\\@<!\.', s:chars_double_lashes, 'g')
491491
let exec_sub_regexp = substitute(sub_regexp, '\$$', '\\*$', '')
492492

493493
exec 'syn match '.label_identifier.' "\v\c'.sub_regexp.'" containedin=NERDTreeFile'

0 commit comments

Comments
 (0)