Add byte limit for look-behind pattern

The TagbarKind syntax match pattern has a zero-width look-behind atom
with unlimited length. This can slow down syntax highlighting. Since in
this case there can only be 1 or 2 characters that get matched, we can
set a limit for the match, thus speeding up the matching.

Since the limit unfortunately works with bytes instead of characters,
use 3 instead of 2 to account for double-width folding characters.
This commit is contained in:
Jan Larres 2017-09-12 13:30:22 +12:00
parent 7299257d77
commit d4a08c33e5

View File

@ -12,7 +12,8 @@ if exists("b:current_syntax")
endif
let s:ics = escape(join(g:tagbar_iconchars, ''), ']^\-')
let s:pattern = '\(^[' . s:ics . '] \?\)\@<=[^-+: ]\+[^:]\+$'
let s:pattern = '\(^[' . s:ics . '] \?\)\@3<=[^-+: ]\+[^:]\+$'
execute "syntax match TagbarKind '" . s:pattern . "'"
let s:pattern = '\(\S\@<![' . s:ics . '][-+# ]\?\)\@<=[^*(]\+\(\*\?\(([^)]\+)\)\? :\)\@='