Skip to content

Commit aded554

Browse files
littlewu2508chrisbra
authored andcommitted
runtime(make): Move target greedy match after $() to avoid region matching overflow
Partially revert 2a33b49, where all syn match makeIdent are moved before syn region makeIdent to match $() (reason: see vim/vim#18403 (comment)) However this results in vim/vim#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: #18890 closes: #18938 Signed-off-by: Yiyang Wu <xgreenlandforwyy@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 8ea0e72 commit aded554

3 files changed

Lines changed: 34 additions & 4 deletions

File tree

runtime/syntax/make.vim

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
" 2025 Apr 15 by Vim project: rework Make flavor detection (#17089)
88
" 2025 Oct 12 by Vim project: update makeDefine highlighting (#18403)
99
" 2025 Oct 25 by Vim project: update makeTargetinDefine highlighting (#18570)
10+
" 2025 Dec 23 by Vim project: fix too greedy match (#18938)
1011

1112
" quit when a syntax file was already loaded
1213
if exists("b:current_syntax")
@@ -40,10 +41,6 @@ syn match makeIdent "\$\$\w*"
4041
syn match makeIdent "\$\$\$\$\w*" containedin=makeDefine
4142
syn match makeIdent "\$[^({]"
4243
syn match makeIdent "\$\$[^({]" containedin=makeDefine
43-
syn match makeIdent "^ *[^:#= \t]*\s*[:+?!*]="me=e-2
44-
syn match makeIdent "^ *[^:#= \t]*\s*::="me=e-3
45-
syn match makeIdent "^ *[^:#= \t]*\s*="me=e-1
46-
syn match makeIdent "%"
4744
if get(b:, 'make_flavor', s:make_flavor) == 'microsoft'
4845
syn region makeIdent start="\$(" end=")" contains=makeStatement,makeIdent
4946
syn region makeIdent start="\${" end="}" contains=makeStatement,makeIdent
@@ -55,6 +52,10 @@ else
5552
syn region makeIdent start="\$\$(" skip="\\)\|\\\\" end=")" containedin=makeDefine contains=makeStatement,makeIdent
5653
syn region makeIdent start="\$\${" skip="\\}\|\\\\" end="}" containedin=makeDefine contains=makeStatement,makeIdent
5754
endif
55+
syn match makeIdent "^ *[^:#= \t]*\s*[:+?!*]="me=e-2
56+
syn match makeIdent "^ *[^:#= \t]*\s*::="me=e-3
57+
syn match makeIdent "^ *[^:#= \t]*\s*="me=e-1
58+
syn match makeIdent "%"
5859

5960
" Makefile.in variables
6061
syn match makeConfig "@[A-Za-z0-9_]\+@"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
>#+0#0000e05#ffffff0| |c|o|m@1|e|n|t| +0#0000000&@65
2+
@75
3+
|a+0#00e0e07&| |=+0#0000000&| |b| @69
4+
|$+0#00e0e07&|(|a|)| |=+0#0000000&| |1| @66
5+
@75
6+
|$+0#00e0e07&|(|a|)|:@1| +0#0000000&@68
7+
| +0#e000e06&@7|@|e+0#e000002&|c|h|o| |d|o|u|b|l|e|-|c|o|l|o|n| |r|u|l|e| +0#0000000&@43
8+
@75
9+
|$+0#00e0e07&|(|a|)| |++0#0000000&|=| |o|u|t|p|u|t| @60
10+
|~+0#4040ff13&| @73
11+
|~| @73
12+
|~| @73
13+
|~| @73
14+
|~| @73
15+
|~| @73
16+
|~| @73
17+
|~| @73
18+
|~| @73
19+
|~| @73
20+
| +0#0000000&@56|1|,|1| @10|A|l@1|
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# comment
2+
3+
a = b
4+
$(a) = 1
5+
6+
$(a)::
7+
@echo double-colon rule
8+
9+
$(a) += output

0 commit comments

Comments
 (0)