Skip to content

Commit b3a1a1c

Browse files
kalafutarp242
authored andcommitted
Improve performance of package comment regex (#1799)
* Improve performance of package comment regex By anchoring to the start of the document (since that's the only place a package comment will appear), the number of false matches is greatly reduced in some files. Fixes #1747 * Simpler version with better tolerance of initial comments
1 parent 7ac1e62 commit b3a1a1c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

syntax/go.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ if go#config#HighlightBuildConstraints() || go#config#FoldEnable('package_commen
355355
\ . ' end=/\v\n\s*package/he=e-7,me=e-7,re=e-7'
356356
\ . ' contains=@goCommentGroup,@Spell'
357357
\ . (go#config#FoldEnable('package_comment') ? ' fold' : '')
358-
exe 'syn region goPackageComment start=/\v\/\*.*\n(.*\n)*\s*\*\/\npackage/'
358+
exe 'syn region goPackageComment start=/\v^\s*\/\*.*\n(.*\n)*\s*\*\/\npackage/'
359359
\ . ' end=/\v\*\/\n\s*package/he=e-7,me=e-7,re=e-7'
360360
\ . ' contains=@goCommentGroup,@Spell'
361361
\ . (go#config#FoldEnable('package_comment') ? ' fold' : '')

0 commit comments

Comments
 (0)