commit 081feae3a31f2165322d03eb4842a0f0dec90aec
parent dfcf03b1baf801460a35f40168889de67822f81f
Author: zeertzjq <zeertzjq@outlook.com>
Date: Wed, 24 Dec 2025 08:45:02 +0800
vim-patch:aded554: runtime(make): Move target greedy match after $() to avoid region matching overflow
Partially revert 2a33b499a3d7f46dc307234847a6562cef6cf1d8, where all
syn match makeIdent are moved before syn region makeIdent to match $()
(reason: see https://github.com/vim/vim/pull/18403#issuecomment-3341161566)
However this results in https://github.com/vim/vim/issues/18890 ,
because lines like
`$(a) =`
will first start a region search beginning with `$(`
but then the whole target including `)` will be matched by
`syn match makeIdent "^ *[^:#= \t]*\s*="me=e-1`
which leaves the region search for the never-found `)` and let the
region matching overflow.
Same for
`$(a) ::`
`$(a) +=`
The solution is to move those greedy target match back, so they take
priority and prevents region match from happening.
fixes: vim/vim#18890
closes: vim/vim#18938
https://github.com/vim/vim/commit/aded55463a150bc9c77852f8e2c931535bedad3e
Co-authored-by: Yiyang Wu <xgreenlandforwyy@gmail.com>
Diffstat:
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/runtime/syntax/make.vim b/runtime/syntax/make.vim
@@ -7,6 +7,7 @@
" 2025 Apr 15 by Vim project: rework Make flavor detection (#17089)
" 2025 Oct 12 by Vim project: update makeDefine highlighting (#18403)
" 2025 Oct 25 by Vim project: update makeTargetinDefine highlighting (#18570)
+" 2025 Dec 23 by Vim project: fix too greedy match (#18938)
" quit when a syntax file was already loaded
if exists("b:current_syntax")
@@ -40,10 +41,6 @@ syn match makeIdent "\$\$\w*"
syn match makeIdent "\$\$\$\$\w*" containedin=makeDefine
syn match makeIdent "\$[^({]"
syn match makeIdent "\$\$[^({]" containedin=makeDefine
-syn match makeIdent "^ *[^:#= \t]*\s*[:+?!*]="me=e-2
-syn match makeIdent "^ *[^:#= \t]*\s*::="me=e-3
-syn match makeIdent "^ *[^:#= \t]*\s*="me=e-1
-syn match makeIdent "%"
if get(b:, 'make_flavor', s:make_flavor) == 'microsoft'
syn region makeIdent start="\$(" end=")" contains=makeStatement,makeIdent
syn region makeIdent start="\${" end="}" contains=makeStatement,makeIdent
@@ -55,6 +52,10 @@ else
syn region makeIdent start="\$\$(" skip="\\)\|\\\\" end=")" containedin=makeDefine contains=makeStatement,makeIdent
syn region makeIdent start="\$\${" skip="\\}\|\\\\" end="}" containedin=makeDefine contains=makeStatement,makeIdent
endif
+syn match makeIdent "^ *[^:#= \t]*\s*[:+?!*]="me=e-2
+syn match makeIdent "^ *[^:#= \t]*\s*::="me=e-3
+syn match makeIdent "^ *[^:#= \t]*\s*="me=e-1
+syn match makeIdent "%"
" Makefile.in variables
syn match makeConfig "@[A-Za-z0-9_]\+@"