runtime(sh): Keep function name patterns engine neutral
Commit:
https://github.com/vim/vim/commit/12f6f20552187432ac67e3bd83a285a1e608b457
Author: Aliaksei Budavei <[email protected]>
Date: Thu Apr 2 16:59:28 2026 +0000
runtime(sh): Keep function name patterns engine neutral
Request less backtracking to function-name candidates for
nonlinear patterns with any regexp engine BUT force using
the old engine with these patterns to avoid incurring an
additional penalty, according to ":syntime report", when the
new regexp engine is preferred.
fixes: #19847
closes: #19849
Signed-off-by: Aliaksei Budavei <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/runtime/syntax/sh.vim b/runtime/syntax/sh.vim
index f9aaa932a..05eb488d5 100644
--- a/runtime/syntax/sh.vim
+++ b/runtime/syntax/sh.vim
@@ -23,6 +23,7 @@
" 2026 Feb 11 improve support for KornShell function names and
variables
" 2026 Feb 15 improve comment handling #19414
" 2026 Mar 23 improve matching of function definitions #19638
+" 2026 Apr 02 improve matching of function definitions #19849
" }}}
" Version: 208
" Former URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH
@@ -665,12 +666,12 @@ ShFoldFunctions syn region shFunctionSubSh
matchgroup=shFunctionSubShRegion star
if exists("b:is_bash")
syn keyword shFunctionKey coproc
- syn match shFunctionCmdOne "^\s*\zs\%(\<\k\+\|[^()<>|&$;
]\+\)\+\s*()\ze\_s*\%(\%(for\|case\|select\|if\|while\|until\)\>\|\[\[\s\|((\)"
skipwhite skipnl nextgroup=@shFunctionCmds
- syn match shFunctionCmdTwo "\%(\<\k\+\>\|[^()<>|&$;
]\+\)\+\ze\s*\%(()\ze\)\=\_s*\%(\<\%(for\|case\|select\|if\|while\|until\)\>\|\[\[\s\|((\)"
contained skipwhite skipnl nextgroup=@shFunctionCmds
- syn match shFunctionOne "^\s*\zs\%(\<\k\+\|[^()<>|&$;
]\+\)\+\s*()\ze\_s*{" skipwhite skipnl nextgroup=shFunctionExpr
- syn match shFunctionTwo "\%(\<\k\+\|[^()<>|&$;
]\+\)\+\ze\s*\%(()\ze\)\=\_s*{" contained skipwhite skipnl
nextgroup=shFunctionExpr
- syn match shFunctionThree "^\s*\zs\%(\<\k\+\|[^()<>|&$;
]\+\)\+\s*()\ze\_s*((\@!" skipwhite skipnl nextgroup=shFunctionSubSh
- syn match shFunctionFour "\%(\<\k\+\|[^()<>|&$;
]\+\)\+\ze\s*\%(\%(()\ze\)\=\)\@>\_s*((\@!" contained skipwhite skipnl
nextgroup=shFunctionSubSh
+ syn match shFunctionCmdOne "\%#=1^\s*\zs\%(\%(\<\k\+\|[^()<>|&$;
]\+\)\+\)\@>\s*()\ze\_s*\%(\%(for\|case\|select\|if\|while\|until\)\>\|\[\[\s\|((\)"
skipwhite skipnl nextgroup=@shFunctionCmds
+ syn match shFunctionCmdTwo "\%#=1\%(\%(\<\k\+\>\|[^()<>|&$;
]\+\)\+\)\@>\ze\s*\%(()\ze\)\=\_s*\%(\<\%(for\|case\|select\|if\|while\|until\)\>\|\[\[\s\|((\)"
contained skipwhite skipnl nextgroup=@shFunctionCmds
+ syn match shFunctionOne "\%#=1^\s*\zs\%(\%(\<\k\+\|[^()<>|&$;
]\+\)\+\)\@>\s*()\ze\_s*{" skipwhite skipnl nextgroup=shFunctionExpr
+ syn match shFunctionTwo "\%#=1\%(\%(\<\k\+\|[^()<>|&$;
]\+\)\+\)\@>\ze\s*\%(()\ze\)\=\_s*{" contained skipwhite skipnl
nextgroup=shFunctionExpr
+ syn match shFunctionThree "\%#=1^\s*\zs\%(\%(\<\k\+\|[^()<>|&$;
]\+\)\+\)\@>\s*()\ze\_s*((\@!" skipwhite skipnl nextgroup=shFunctionSubSh
+ syn match shFunctionFour "\%#=1\%(\%(\<\k\+\|[^()<>|&$;
]\+\)\+\)\@>\ze\s*\%(\%(()\ze\)\=\)\@>\_s*((\@!" contained skipwhite
skipnl nextgroup=shFunctionSubSh
elseif exists("b:is_ksh88")
" AT&T ksh88
syn match shFunctionCmdOne
"^\s*\zs\h\w*\s*()\ze\_s*\%(\%(for\|case\|select\|if\|while\|until\)\>\|\[\[\s\|((\)"
skipwhite skipnl nextgroup=@shFunctionCmds
@@ -681,13 +682,13 @@ elseif exists("b:is_mksh")
" MirBSD ksh is the wild west of absurd and abstruse function names...
syn match shFunctionCmdOne
"^\s*\zs[-A-Za-z_@!+.%,0-9:]*[-A-Za-z_.%,0-9:]\s*()\ze\_s*\%(\%(for\|case\|select\|if\|while\|until\)\>\|\[\[\s\|((\)"
skipwhite skipnl nextgroup=@shFunctionCmds
syn match shFunctionOne
"^\s*\zs[-A-Za-z_@!+.%,0-9:]*[-A-Za-z_.%,0-9:]\s*()\ze\_s*{" skipwhite
skipnl nextgroup=shFunctionExpr
- syn match shFunctionTwo
"\%([@!+.%,:-]\+\|\<\w\+\)*[-A-Za-z_.%,0-9:]\ze\s*\%(()\ze\)\=\_s*{"
contained skipwhite skipnl nextgroup=shFunctionExpr
+ syn match shFunctionTwo
"\%#=1\%(\%(\<\w\+\|[@!+.%,:-]\+\)*[-A-Za-z_.%,0-9:]\)\@>\ze\s*\%(()\ze\)\=\_s*{"
contained skipwhite skipnl nextgroup=shFunctionExpr
syn match shFunctionThree
"^\s*\zs[-A-Za-z_@!+.%,0-9:]*[-A-Za-z_.%,0-9:]\s*()\ze\_s*((\@!"
skipwhite skipnl nextgroup=shFunctionSubSh
elseif exists("b:is_kornshell")
" ksh93
syn match shFunctionCmdOne
"^\s*\zs[A-Za-z_.][A-Za-z_.0-9]*\s*()\ze\_s*\%(\%(for\|case\|select\|if\|while\|until\)\>\|\[\[\s\|((\)"
skipwhite skipnl nextgroup=@shFunctionCmds
syn match shFunctionOne "^\s*\zs[A-Za-z_.][A-Za-z_.0-9]*\s*()\ze\_s*{"
skipwhite skipnl nextgroup=shFunctionExpr
- syn match shFunctionTwo "\%(\.\|\<\h\+\)[A-Za-z_.0-9]*\ze\_s*{"
contained skipwhite skipnl nextgroup=shFunctionExpr
+ syn match shFunctionTwo "\%(\<\h\+\|\.\)[A-Za-z_.0-9]*\ze\_s*{"
contained skipwhite skipnl nextgroup=shFunctionExpr
syn match shFunctionThree
"^\s*\zs[A-Za-z_.][A-Za-z_.0-9]*\s*()\ze\_s*((\@!" skipwhite skipnl
nextgroup=shFunctionSubSh
syn match shNamespaceOne "\<\h\w*\>\ze\_s*{" contained skipwhite
skipnl nextgroup=shFunctionExpr
else
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1w8LOo-000nGd-MJ%40256bit.org.