runtime(vim): Update base-syntax, fix nested function folding (#14397)

Commit: 
https://github.com/vim/vim/commit/4ba70cab37d2a625d8c59bb136070ef9d1976934
Author: dkearns <dougkea...@gmail.com>
Date:   Mon Apr 15 04:32:56 2024 +1000

    runtime(vim): Update base-syntax, fix nested function folding 
(https://github.com/vim/vim/issues/14397)
    
    Only match function folding start and end patterns at the start of a
    line, excluding heredocs and :append/:change/:insert commands.
    
    Fixes #14393
    
    Signed-off-by: Christian Brabandt <c...@256bit.org>
    Signed-off-by: Doug Kearns <dougkea...@gmail.com>

diff --git a/runtime/syntax/generator/vim.vim.base 
b/runtime/syntax/generator/vim.vim.base
index f5e2110a2..90e1ee59b 100644
--- a/runtime/syntax/generator/vim.vim.base
+++ b/runtime/syntax/generator/vim.vim.base
@@ -3,7 +3,7 @@
 " Maintainer:     Hirohito Higashi <h.east.727 ATMARK gmail.com>
 "         Doug Kearns <dougkea...@gmail.com>
 " URL:    https://github.com/vim-jp/syntax-vim-ex
-" Last Change:    2024 Apr 12
+" Last Change:    2024 Apr 13
 " Former Maintainer: Charles E. Campbell
 
 " DO NOT CHANGE DIRECTLY.
@@ -191,9 +191,9 @@ syn cluster vimExprList 
contains=vimEnvvar,vimFunc,vimFuncVar,vimNumber,vimOper,
 "   (buftype != nofile test avoids having append, change, insert show up in 
the command window)
 " =======================
 if &buftype != 'nofile'
- syn region vimInsert  matchgroup=vimCommand start="^[:        
]*\(\d\+\(,\d\+\)\=\)\=a\%[ppend]$"             matchgroup=vimCommand 
end="^\.$""
- syn region vimInsert  matchgroup=vimCommand start="^[:        
]*\(\d\+\(,\d\+\)\=\)\=c\%[hange]$"             matchgroup=vimCommand 
end="^\.$""
- syn region vimInsert  matchgroup=vimCommand start="^[:        
]*\(\d\+\(,\d\+\)\=\)\=i\%[nsert]$"             matchgroup=vimCommand 
end="^\.$""
+ syn region vimInsert  matchgroup=vimCommand start="^[:        
]*\(\d\+\(,\d\+\)\=\)\=a\%[ppend]$"             matchgroup=vimCommand 
end="^\.$" extend
+ syn region vimInsert  matchgroup=vimCommand start="^[:        
]*\(\d\+\(,\d\+\)\=\)\=c\%[hange]$"             matchgroup=vimCommand 
end="^\.$" extend
+ syn region vimInsert  matchgroup=vimCommand start="^[:        
]*\(\d\+\(,\d\+\)\=\)\=i\%[nsert]$"             matchgroup=vimCommand 
end="^\.$" extend
 endif
 
 " Behave! {{{2
@@ -244,12 +244,14 @@ if !exists("g:vimsyn_noerror") && 
!exists("g:vimsyn_noopererror")
  syn match     vimOperError    ")"
 endif
 
-" Functions : Tag is provided for those who wish to highlight tagged functions 
{{{2
+" Functions: Tag is provided for those who wish to highlight tagged functions 
{{{2
 " =========
 syn cluster    vimFuncList     
contains=vimFuncBang,vimFunctionError,vimFuncKey,vimFuncSID,Tag
 syn cluster    vimDefList      
contains=vimFuncBang,vimFunctionError,vimDefKey,vimFuncSID,Tag
-syn cluster    vimFuncBodyList 
contains=@vimCmdList,vimCmplxRepeat,vimComment,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimFuncVar,vimLetHereDoc,vimLineComment,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegion,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst
-syn cluster    vimDefBodyList  
contains=@vimCmdList,vimCmplxRepeat,vim9Comment,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimLetHereDoc,vim9LineComment,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegion,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst
+
+syn cluster    vimFuncBodyCommon       
contains=@vimCmdList,vimCmplxRepeat,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimLetHereDoc,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst,vimFuncFold
+syn cluster    vimFuncBodyList 
contains=@vimFuncBodyCommon,vimComment,vimLineComment,vimFuncVar,vimInsert
+syn cluster    vimDefBodyList  
contains=@vimFuncBodyCommon,vim9Comment,vim9LineComment
 
 syn region     vimFuncPattern  contained               matchgroup=vimOper 
start="/" end="$" contains=@vimSubstList
 syn match      vimFunction     "\<fu\%[nction]\>"      skipwhite 
nextgroup=vimCmdSep,vimComment,vimFuncPattern contains=vimFuncKey
@@ -284,9 +286,9 @@ syn match   vimEndfunction  "\<endf\%[unction]\>"
 syn match      vimEnddef       "\<enddef\>"
 
 if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f'
- syn region    vimFuncFold     
start="\<fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+\s*("
        end="\<endf\%[unction]\>" contains=vimFunction fold keepend transparent
- syn region    vimFuncFold     
start="\<def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\)\+("               
end="\<enddef\>"                contains=vimDef      fold keepend transparent
- syn region    vimFuncFold     start="\<def\s\+new\i\+("                       
        end="\<enddef\>"                contains=vimDef      fold keepend 
transparent
+ syn region    vimFuncFold     
start="^\s*:\=\s*fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+\s*("
        end="^\s*:\=\s*endf\%[unction]\>" contains=vimFunction fold keepend 
extend transparent
+ syn region    vimFuncFold     
start="^\s*:\=\s*def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\)\+("       
        end="^\s*:\=\s*enddef\>"          contains=vimDef      fold keepend 
extend transparent
+ syn region    vimFuncFold     start="^\s*:\=\s*def\s\+new\i\+("               
                        end="^\s*:\=\s*enddef\>"          contains=vimDef      
fold keepend extend transparent
 endif
 
 syn match      vimFuncVar   contained  "a:\%(\K\k*\|\d\+\)\>"
@@ -502,7 +504,7 @@ syn keyword vimUnlet        unl[et]         skipwhite 
nextgroup=vimUnletBang,vimUnletVars
 syn match      vimUnletBang    contained       "!"     skipwhite 
nextgroup=vimUnletVars
 syn region     vimUnletVars    contained       start="$\I\|\h" skip="
\s*\" end="$" end="|" contains=vimVar,vimEnvvar,vimContinue,vimString,vimNumber
 
-VimFoldh syn region vimLetHereDoc      matchgroup=vimLetHereDocStart 
start='=<<\s*\%(trim\s\+\%(eval\s\+\)\=\|eval\s\+\%(trim\s\+\)\=\)\=\z(\L\S*\)' 
matchgroup=vimLetHereDocStop end='^\s*\z1\s*$'
+VimFoldh syn region vimLetHereDoc      matchgroup=vimLetHereDocStart 
start='=<<\s*\%(trim\s\+\%(eval\s\+\)\=\|eval\s\+\%(trim\s\+\)\=\)\=\z(\L\S*\)' 
matchgroup=vimLetHereDocStop end='^\s*\z1\s*$' extend
 syn keyword    vimLet  var             skipwhite 
nextgroup=vimVar,vimFuncVar,vimLetHereDoc
 
 " For: {{{2
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_fold_01.dump 
b/runtime/syntax/testdir/dumps/vim_ex_def_fold_01.dump
index 4f80331b5..fa5ed9f5a 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_def_fold_01.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_01.dump
@@ -17,4 +17,4 @@
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f|!| |F|o@1|(|)|:| 
|n|u|m|b|e|r|-@42
 | +0#0000000#ffffff0@74
-@57|1|9|,|1| @9|1|6|%| 
+@57|1|9|,|1| @9|1|2|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_fold_02.dump 
b/runtime/syntax/testdir/dumps/vim_ex_def_fold_02.dump
index bbd362c83..2cfdcd4ea 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_def_fold_02.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_02.dump
@@ -17,4 +17,4 @@
 | +0#0000000#ffffff0@74
 |"+0#0000e05&| |s|a|m|e| |n|a|m|e| |a|s| |a|n| |E|x| |c|o|m@1|a|n|d| 
+0#0000000&@46
 |++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |s|:|l|s|(|)|-@50
-| +0#0000000#ffffff0@56|3|7|,|1| @9|3|4|%| 
+| +0#0000000#ffffff0@56|3|7|,|1| @9|2|7|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_fold_03.dump 
b/runtime/syntax/testdir/dumps/vim_ex_def_fold_03.dump
index 7ba9744e8..667341512 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_def_fold_03.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_03.dump
@@ -17,4 +17,4 @@
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|:| 
|l|i|s|t|<|d|i|c|t|<|n|u|m|b|e|r|>@1|-@31
 | +0#0000000#ffffff0@74
-@57|5@1|,|1| @9|5@1|%| 
+@57|5@1|,|1| @9|4@1|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_fold_04.dump 
b/runtime/syntax/testdir/dumps/vim_ex_def_fold_04.dump
index 66c845b2b..d2f047b06 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_def_fold_04.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_04.dump
@@ -17,4 +17,4 @@
 |++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
 | +0#0000000#ffffff0@74
 @75
-@57|7|3|,|1| @9|7@1|%| 
+@57|7|3|,|1| @9|6|2|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_fold_05.dump 
b/runtime/syntax/testdir/dumps/vim_ex_def_fold_05.dump
index 688b788eb..e2decdb0a 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_def_fold_05.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_05.dump
@@ -15,6 +15,6 @@
 @75
 |++0#0000e05#a8a8a8255|-@1| @1|4| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
 | +0#0000000#ffffff0@74
-|~+0#4040ff13&| @73
-|~| @73
-| +0#0000000&@56|9|1|,|0|-|1| @7|B|o|t| 
+@75
+|"+0#0000e05&| |f|o|l|d|-|r|e|g|i|o|n| |e|n|d|i|n|g| +0#0000000&@54
+@57|9|1|,|0|-|1| @7|8|2|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_fold_06.dump 
b/runtime/syntax/testdir/dumps/vim_ex_def_fold_06.dump
index c93c67166..2997eb863 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_def_fold_06.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_06.dump
@@ -1,20 +1,20 @@
-| +0&#ffffff0@74
-|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
-| +0#0000000#ffffff0@74
-@75
-|"+0#0000e05&| |p|a|r|a|m|e|t|e|r|s| +0#0000000&@62
-> @74
-|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|x|:| 
|b|o@1|l|,| |y| |=| |4|2|,| |z|:| |s|t|r|i|n|g| |=| |"|z|e|d|"|)|-@17
-| +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|-@52
 | +0#0000000#ffffff0@74
 @75
 |"+0#0000e05&| |c|o|m@1|e|n|t|s| +0#0000000&@64
 @75
-|++0#0000e05#a8a8a8255|-@1| @1|4| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+>++0#0000e05#a8a8a8255|-@1| @1|4| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+@75
+|"+0#0000e05&| |f|o|l|d|-|r|e|g|i|o|n| |e|n|d|i|n|g| +0#0000000&@54
+@75
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |:|d|e|f| |F|o@1|(|)|-@50
 | +0#0000000#ffffff0@74
 |~+0#4040ff13&| @73
-|~| @73
-|~| @73
-|~| @73
-| +0#0000000&@56|1|0|9|,|0|-|1| @6|B|o|t| 
+| +0#0000000&@56|1|0|9|,|1| @8|B|o|t| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_fold_07.dump 
b/runtime/syntax/testdir/dumps/vim_ex_def_fold_07.dump
new file mode 100644
index 000000000..b11b61e1c
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_07.dump
@@ -0,0 +1,20 @@
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+> +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |:|d|e|f| |F|o@1|(|)|-@50
+| +0#0000000#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|2|7|,|0|-|1| @6|B|o|t| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_fold_99.dump 
b/runtime/syntax/testdir/dumps/vim_ex_def_fold_99.dump
index f9e9ae099..3020a24ad 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_def_fold_99.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_99.dump
@@ -1,20 +1,20 @@
 | +0&#ffffff0@74
-|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
-| +0#0000000#ffffff0@74
-|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
-| +0#0000000#ffffff0@74
-|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
-| +0#0000000#ffffff0@74
-@75
-|"+0#0000e05&| |p|a|r|a|m|e|t|e|r|s| +0#0000000&@62
-@75
-|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|x|:| 
|b|o@1|l|,| |y| |=| |4|2|,| |z|:| |s|t|r|i|n|g| |=| |"|z|e|d|"|)|-@17
-| +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|-@52
 | +0#0000000#ffffff0@74
 @75
 |"+0#0000e05&| |c|o|m@1|e|n|t|s| +0#0000000&@64
 @75
 |++0#0000e05#a8a8a8255|-@1| @1|4| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+@75
+|"+0#0000e05&| |f|o|l|d|-|r|e|g|i|o|n| |e|n|d|i|n|g| +0#0000000&@54
+@75
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |:|d|e|f| |F|o@1|(|)|-@50
 > +0#0000000#ffffff0@74
-@57|1@1|0|,|0|-|1| @6|B|o|t| 
+@57|1|3|0|,|0|-|1| @6|B|o|t| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_nested_00.dump 
b/runtime/syntax/testdir/dumps/vim_ex_def_nested_00.dump
new file mode 100644
index 000000000..9f6d43744
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_nested_00.dump
@@ -0,0 +1,20 @@
+>v+0#af5f00255#ffffff0|i|m|9|s|c|r|i|p|t| +0#0000000&@64
+|#+0#0000e05&| |V|i|m|9| |:|d|e|f| |c|o|m@1|a|n|d| |(|n|e|s|t|e|d|)| 
+0#0000000&@46
+@75
+|c+0#af5f00255&|l|a|s@1| +0#0000000&|T|e|s|t| @64
+@4|c+0#af5f00255&|o|n|s|t| +0#0000000&|n+0#00e0e07&|a|m|e|:+0#0000000&| 
|s|t|r|i|n|g| @52
+@75
+@4|d+0#af5f00255&|e|f| +0#0000000&|n|e|w|(+0#e000e06&|)| +0#0000000&@61
+@8|d+0#af5f00255&|e|f| +0#0000000&|N|a|m|e|(+0#e000e06&|)|:+0#0000000&| 
|s+0#00e0003&|t|r|i|n|g| +0#0000000&@48
+@12|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|G|i|v|e|N|a|m|e|(+0#e000e06&|)| 
+0#0000000&@43
+@16|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|a|n|y|"| +0#0000000&@46
+@12|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@51
+@75
+@12|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|G|i|v|e|N|a|m|e|(+0#e000e06&|)| 
+0#0000000&@45
+@8|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@60
+@75
+@8|t+0#af5f00255&|h|i|s|.|n+0#0000000&|a|m|e| |=+0#af5f00255&| 
+0#0000000&|N|a|m|e|(+0#e000e06&|)| +0#0000000&@48
+@4|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@64
+|e+0#af5f00255&|n|d|c|l|a|s@1| +0#0000000&@66
+@75
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_nested_99.dump 
b/runtime/syntax/testdir/dumps/vim_ex_def_nested_99.dump
new file mode 100644
index 000000000..15c078a5f
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_nested_99.dump
@@ -0,0 +1,20 @@
+|#+0#0000e05#ffffff0| |V|i|m|9| |:|d|e|f| |c|o|m@1|a|n|d| |(|n|e|s|t|e|d|)| 
+0#0000000&@46
+@75
+|c+0#af5f00255&|l|a|s@1| +0#0000000&|T|e|s|t| @64
+@4|c+0#af5f00255&|o|n|s|t| +0#0000000&|n+0#00e0e07&|a|m|e|:+0#0000000&| 
|s|t|r|i|n|g| @52
+@75
+@4|d+0#af5f00255&|e|f| +0#0000000&|n|e|w|(+0#e000e06&|)| +0#0000000&@61
+@8|d+0#af5f00255&|e|f| +0#0000000&|N|a|m|e|(+0#e000e06&|)|:+0#0000000&| 
|s+0#00e0003&|t|r|i|n|g| +0#0000000&@48
+@12|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|G|i|v|e|N|a|m|e|(+0#e000e06&|)| 
+0#0000000&@43
+@16|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|a|n|y|"| +0#0000000&@46
+@12|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@51
+@75
+@12|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|G|i|v|e|N|a|m|e|(+0#e000e06&|)| 
+0#0000000&@45
+@8|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@60
+@75
+@8|t+0#af5f00255&|h|i|s|.|n+0#0000000&|a|m|e| |=+0#af5f00255&| 
+0#0000000&|N|a|m|e|(+0#e000e06&|)| +0#0000000&@48
+@4|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@64
+|e+0#af5f00255&|n|d|c|l|a|s@1| +0#0000000&@66
+@75
+>e+0#af5f00255&|c|h|o| +0#0000000&|T|e|s|t|.|n|e|w|(+0#e000e06&|)| 
+0#0000000&@59
+@57|2|0|,|1| @9|B|o|t| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_nested_fold_00.dump 
b/runtime/syntax/testdir/dumps/vim_ex_def_nested_fold_00.dump
new file mode 100644
index 000000000..3bcaccc3d
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_nested_fold_00.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@1>v+0#af5f00255#ffffff0|i|m|9|s|c|r|i|p|t| 
+0#0000000&@62
+| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|i|m|9| |:|d|e|f| |c|o|m@1|a|n|d| 
|(|n|e|s|t|e|d|)| +0#0000000&@44
+| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| 
|g|:|v|i|m|s|y|n|_|f|o|l|d|i|n|g| |=| |'|f|'| +0#0000000&@29
+| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l| 
|f|d|c|=|2| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@34
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|c+0#af5f00255#ffffff0|l|a|s@1| +0#0000000&|T|e|s|t| 
@62
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3|c+0#af5f00255&|o|n|s|t| 
+0#0000000&|n+0#00e0e07&|a|m|e|:+0#0000000&| |s|t|r|i|n|g| @50
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| |1@1| |l|i|n|e|s|:| |d|e|f| |n|e|w|(|)|-@49
+| @1|e+0#af5f00255#ffffff0|n|d|c|l|a|s@1| +0#0000000&@64
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|T|e|s|t|.|n|e|w|(+0#e000e06&|)| +0#0000000&@57
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_nested_fold_01.dump 
b/runtime/syntax/testdir/dumps/vim_ex_def_nested_fold_01.dump
new file mode 100644
index 000000000..c1f9fa892
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_nested_fold_01.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l| 
|f|d|c|=|2| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@34
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|c+0#af5f00255#ffffff0|l|a|s@1| +0#0000000&|T|e|s|t| 
@62
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3|c+0#af5f00255&|o|n|s|t| 
+0#0000000&|n+0#00e0e07&|a|m|e|:+0#0000000&| |s|t|r|i|n|g| @50
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| >+|-@1| |1@1| |l|i|n|e|s|:| |d|e|f| |n|e|w|(|)|-@49
+| @1|e+0#af5f00255#ffffff0|n|d|c|l|a|s@1| +0#0000000&@64
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|T|e|s|t|.|n|e|w|(+0#e000e06&|)| +0#0000000&@57
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|9|,|5|-|1| @7|B|o|t| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_nested_fold_99.dump 
b/runtime/syntax/testdir/dumps/vim_ex_def_nested_fold_99.dump
new file mode 100644
index 000000000..84a08f866
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_nested_fold_99.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@1|v+0#af5f00255#ffffff0|i|m|9|s|c|r|i|p|t| 
+0#0000000&@62
+| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|i|m|9| |:|d|e|f| |c|o|m@1|a|n|d| 
|(|n|e|s|t|e|d|)| +0#0000000&@44
+| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| 
|g|:|v|i|m|s|y|n|_|f|o|l|d|i|n|g| |=| |'|f|'| +0#0000000&@29
+| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l| 
|f|d|c|=|2| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@34
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|c+0#af5f00255#ffffff0|l|a|s@1| +0#0000000&|T|e|s|t| 
@62
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3|c+0#af5f00255&|o|n|s|t| 
+0#0000000&|n+0#00e0e07&|a|m|e|:+0#0000000&| |s|t|r|i|n|g| @50
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| |1@1| |l|i|n|e|s|:| |d|e|f| |n|e|w|(|)|-@49
+| @1|e+0#af5f00255#ffffff0|n|d|c|l|a|s@1| +0#0000000&@64
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1>e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|T|e|s|t|.|n|e|w|(+0#e000e06&|)| +0#0000000&@57
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|2@1|,|1| @9|A|l@1| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_fold_01.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_fold_01.dump
index 461531d1b..9034e28a0 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_01.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_01.dump
@@ -17,4 +17,4 @@
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|{|"|F|"|}|{|"|o|"|}|{|"|o|"|}|(|)|-@34
 | +0#0000000#ffffff0@74
-@57|1|9|,|1| @10|8|%| 
+@57|1|9|,|1| @10|6|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_fold_02.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_fold_02.dump
index 3a64c7f12..17e220f4a 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_02.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_02.dump
@@ -17,4 +17,4 @@
 |++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|g|:|F|o@1|(|)|-@44
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|s|:|F|o@1|(|)|-@44
-| +0#0000000#ffffff0@56|3|7|,|1| @9|1|8|%| 
+| +0#0000000#ffffff0@56|3|7|,|1| @9|1|4|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_fold_03.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_fold_03.dump
index 3f26306d7..b229e6c9a 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_03.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_03.dump
@@ -17,4 +17,4 @@
 | +0#0000000#ffffff0@74
 @75
 |"+0#0000e05&| |m|o|d|i|f|i|e|r|s| +0#0000000&@63
-@57|5@1|,|0|-|1| @7|2|8|%| 
+@57|5@1|,|0|-|1| @7|2@1|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_fold_04.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_fold_04.dump
index 52423a2a2..d9aa1c9f3 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_04.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_04.dump
@@ -17,4 +17,4 @@
 |++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)| 
|a|b|o|r|t|-@40
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)| 
|d|i|c|t|-@41
-| +0#0000000#ffffff0@56|7|3|,|1| @9|4|1|%| 
+| +0#0000000#ffffff0@56|7|3|,|1| @9|3|2|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_fold_05.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_fold_05.dump
index d2acafc46..989c504e8 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_05.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_05.dump
@@ -17,4 +17,4 @@
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n|!| 
|F|o@1|(|)| |d|i|c|t|-@40
 | +0#0000000#ffffff0@74
-@57|9|1|,|1| @9|5|4|%| 
+@57|9|1|,|1| @9|4|2|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_fold_06.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_fold_06.dump
index 354af8ebb..f6619c255 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_06.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_06.dump
@@ -17,4 +17,4 @@
 |++0#0000e05#a8a8a8255|-@1| @1|4| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
-| +0#0000000#ffffff0@56|1|0|9|,|1| @8|6|7|%| 
+| +0#0000000#ffffff0@56|1|0|9|,|1| @8|5|2|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_fold_07.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_fold_07.dump
index fc403c59b..8e8421409 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_07.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_07.dump
@@ -17,4 +17,4 @@
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|-@47
 | +0#0000000#ffffff0@74
-@57|1|2|7|,|0|-|1| @6|8|0|%| 
+@57|1|2|7|,|0|-|1| @6|6|3|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_fold_08.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_fold_08.dump
index 4d519d010..fb482ff92 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_08.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_08.dump
@@ -17,4 +17,4 @@
 |++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
 | +0#0000000#ffffff0@74
 @75
-@57|1|4|5|,|3|-|1| @6|9|5|%| 
+@57|1|4|5|,|3|-|1| @6|7|4|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_fold_09.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_fold_09.dump
index 8ecc52969..4b6a2d2cd 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_09.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_09.dump
@@ -17,4 +17,4 @@
 |d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| 
+0#0000000&|f|o@1|.+0#af5f00255&|b+0#0000000&|a|r| @55
 |d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n|!| +0#0000000&|F|o@1| @58
 |d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| 
+0#0000000&|f|o@1|.+0#af5f00255&|b+0#0000000&|a|r| @55
-@57|1|6|3|,|7|-|1| @6|9@1|%| 
+@57|1|6|3|,|7|-|1| @6|7|8|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_fold_10.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_fold_10.dump
new file mode 100644
index 000000000..2e986c456
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_10.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@74
+|"+0#0000e05&| |d|e|l|e|t|e| |f|u|n|c|t|i|o|n| +0#0000000&@57
+@75
+|d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| +0#0000000&|F|o@1| @59
+|d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| 
+0#0000000&|f|o@1|.+0#af5f00255&|b+0#0000000&|a|r| @55
+>d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n|!| +0#0000000&|F|o@1| @58
+|d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| 
+0#0000000&|f|o@1|.+0#af5f00255&|b+0#0000000&|a|r| @55
+@75
+@75
+|"+0#0000e05&| |f|o|l|d|-|r|e|g|i|o|n| |e|n|d|i|n|g| +0#0000000&@54
+@75
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|6| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+@57|1|8|1|,|1| @8|9|1|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_fold_11.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_fold_11.dump
new file mode 100644
index 000000000..174e250b5
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_11.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+>++0#0000e05#a8a8a8255|-@1| @1|6| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|6| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |:|f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@45
+| +0#0000000#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|9@1|,|0|-|1| @6|B|o|t| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_fold_12.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_fold_12.dump
new file mode 100644
index 000000000..d68f8a123
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_12.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|6| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+>++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |:|f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@45
+| +0#0000000#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|2|1|7|,|5|-|1| @6|B|o|t| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_fold_99.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_fold_99.dump
index b6770ef18..04aa4ba78 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_99.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_99.dump
@@ -1,20 +1,20 @@
-|++0#0000e05#a8a8a8255|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|-@47
+|d+0#af5f00255#ffffff0|e|l|f|u|n|c|t|i|o|n| 
+0#0000000&|f|o@1|.+0#af5f00255&|b+0#0000000&|a|r| @55
+@75
+@75
+|"+0#0000e05&| |f|o|l|d|-|r|e|g|i|o|n| |e|n|d|i|n|g| +0#0000000&@54
+@75
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
 | +0#0000000#ffffff0@74
-|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|x|,| |y| |=| |4|2|,| |z| |=| |"|z|e|d|"|)|-@26
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
 | +0#0000000#ffffff0@74
-|++0#0000e05#a8a8a8255|-@1| @1|6| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|-@47
+|++0#0000e05#a8a8a8255|-@1| @1|6| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
 | +0#0000000#ffffff0@74
-@75
-|"+0#0000e05&| |c|o|m@1|e|n|t|s| +0#0000000&@64
-@75
 |++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
 | +0#0000000#ffffff0@74
-@75
-|"+0#0000e05&| |d|e|l|e|t|e| |f|u|n|c|t|i|o|n| +0#0000000&@57
-@75
-|d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| +0#0000000&|F|o@1| @59
-|d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| 
+0#0000000&|f|o@1|.+0#af5f00255&|b+0#0000000&|a|r| @55
-|d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n|!| +0#0000000&|F|o@1| @58
-|d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| 
+0#0000000&|f|o@1|.+0#af5f00255&|b+0#0000000&|a|r| @55
-> @74
-@57|1|8|3|,|0|-|1| @6|B|o|t| 
+|++0#0000e05#a8a8a8255|-@1| @1|6| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |:|f|u|n|c|t|i|o|n| 
|F|o@1|(|)|-@45
+> +0#0000000#ffffff0@74
+@57|2@1|3|,|0|-|1| @6|B|o|t| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_nested_00.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_nested_00.dump
new file mode 100644
index 000000000..6f0ca86a2
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_nested_00.dump
@@ -0,0 +1,20 @@
+>"+0#0000e05#ffffff0| |V|i|m| |:|d|e|f| |a|n|d| |:|f|u|n|c|t|i|o|n| 
|c|o|m@1|a|n|d|s| |(|n|e|s|t|e|d|)| +0#0000000&@32
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|u|n|A|(+0#e000e06&|)|:+0#0000000&| 
|s+0#00e0003&|t|r|i|n|g| +0#0000000&@56
+@4|d+0#af5f00255&|e|f| +0#0000000&|D|o|F|u|n|A|(+0#e000e06&|)|:+0#0000000&| 
|s+0#00e0003&|t|r|i|n|g| +0#0000000&@50
+@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|.|"| +0#0000000&@56
+@4|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@64
+@75
+@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|D|o|F|u|n|A|(+0#e000e06&|)| 
+0#0000000&@55
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|u|n|B|(+0#e000e06&|)|:+0#0000000&| 
|s+0#00e0003&|t|r|i|n|g| +0#0000000&@56
+@4|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|D|o|F|u|n|B|(+0#e000e06&|)| 
+0#0000000&@53
+@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|.@1|"| +0#0000000&@55
+@4|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@59
+@75
+@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|D|o|F|u|n|B|(+0#e000e06&|)| 
+0#0000000&@55
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|F|u|n|C|(+0#e000e06&|)| 
+0#0000000&@59
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_nested_01.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_nested_01.dump
new file mode 100644
index 000000000..640bdf554
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_nested_01.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@3|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@59
+@75
+@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|D|o|F|u|n|B|(+0#e000e06&|)| 
+0#0000000&@55
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+>f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|F|u|n|C|(+0#e000e06&|)| 
+0#0000000&@59
+@4|d+0#af5f00255&|e|f| +0#0000000&|D|o|F|u|n|C|(+0#e000e06&|)|:+0#0000000&| 
|s+0#00e0003&|t|r|i|n|g| +0#0000000&@50
+@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|.@2|"| +0#0000000&@54
+@4|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@64
+@75
+@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|D|o|F|u|n|C|(+0#e000e06&|)| 
+0#0000000&@55
+|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@63
+@75
+|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|F|u|n|D|(+0#e000e06&|)| 
+0#0000000&@59
+@4|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|D|o|F|u|n|D|(+0#e000e06&|)| 
+0#0000000&@53
+@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|.@3|"| +0#0000000&@53
+@4|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@59
+@75
+@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|D|o|F|u|n|D|(+0#e000e06&|)| 
+0#0000000&@55
+@57|1|9|,|1| @9|6|8|%| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_nested_99.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_nested_99.dump
new file mode 100644
index 000000000..6ef83ef43
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_nested_99.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@3|d+0#af5f00255&|e|f| 
+0#0000000&|D|o|F|u|n|C|(+0#e000e06&|)|:+0#0000000&| |s+0#00e0003&|t|r|i|n|g| 
+0#0000000&@50
+@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|.@2|"| +0#0000000&@54
+@4|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@64
+@75
+@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|D|o|F|u|n|C|(+0#e000e06&|)| 
+0#0000000&@55
+|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@63
+@75
+|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|F|u|n|D|(+0#e000e06&|)| 
+0#0000000&@59
+@4|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|D|o|F|u|n|D|(+0#e000e06&|)| 
+0#0000000&@53
+@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|.@3|"| +0#0000000&@53
+@4|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@59
+@75
+@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|D|o|F|u|n|D|(+0#e000e06&|)| 
+0#0000000&@55
+|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@63
+@75
+|e+0#af5f00255&|c|h|o| +0#0000000&|F|u|n|A|(+0#e000e06&|)| +0#0000000&@63
+|e+0#af5f00255&|c|h|o| +0#0000000&|F|u|n|B|(+0#e000e06&|)| +0#0000000&@63
+|e+0#af5f00255&|c|h|o| +0#0000000&|F|u|n|C|(+0#e000e06&|)| +0#0000000&@63
+>e+0#af5f00255&|c|h|o| +0#0000000&|F|u|n|D|(+0#e000e06&|)| +0#0000000&@63
+@57|3|8|,|1| @9|B|o|t| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_00.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_00.dump
new file mode 100644
index 000000000..7d658b742
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_00.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@1>"+0&#ffffff0| |V|i|m| |:|d|e|f| |a|n|d| 
|:|f|u|n|c|t|i|o|n| |c|o|m@1|a|n|d|s| |(|n|e|s|t|e|d|)| +0#0000000&@30
+| +0#0000e05#a8a8a8255@1|"+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| 
|g|:|v|i|m|s|y|n|_|f|o|l|d|i|n|g| |=| |'|f|'| +0#0000000&@29
+| +0#0000e05#a8a8a8255@1|"+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l| 
|f|d|c|=|2| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@34
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |d|e|f| |F|u|n|A|(|)|:| 
|s|t|r|i|n|g|-@40
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |d|e|f| |F|u|n|B|(|)|:| 
|s|t|r|i|n|g|-@40
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|u|n|C|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|u|n|D|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|A|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|B|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|C|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|D|(+0#e000e06&|)| +0#0000000&@61
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_01.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_01.dump
new file mode 100644
index 000000000..96c1d34af
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_01.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@1|"+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| 
|g|:|v|i|m|s|y|n|_|f|o|l|d|i|n|g| |=| |'|f|'| +0#0000000&@29
+| +0#0000e05#a8a8a8255@1|"+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l| 
|f|d|c|=|2| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@34
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |d|e|f| |F|u|n|A|(|)|:| 
|s|t|r|i|n|g|-@40
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| >+|-@1| @1|7| |l|i|n|e|s|:| |d|e|f| |F|u|n|B|(|)|:| 
|s|t|r|i|n|g|-@40
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|u|n|C|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|u|n|D|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|A|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|B|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|C|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|D|(+0#e000e06&|)| +0#0000000&@61
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|9|,|1| @9|B|o|t| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_02.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_02.dump
new file mode 100644
index 000000000..977aaa883
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_02.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|u|n|C|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|u|n|D|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1>e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|A|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|B|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|C|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|D|(+0#e000e06&|)| +0#0000000&@61
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|3|7|,|1| @9|B|o|t| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_99.dump 
b/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_99.dump
new file mode 100644
index 000000000..ad1fc05cd
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_99.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@1|"+0&#ffffff0| |V|i|m| |:|d|e|f| |a|n|d| 
|:|f|u|n|c|t|i|o|n| |c|o|m@1|a|n|d|s| |(|n|e|s|t|e|d|)| +0#0000000&@30
+| +0#0000e05#a8a8a8255@1|"+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| 
|g|:|v|i|m|s|y|n|_|f|o|l|d|i|n|g| |=| |'|f|'| +0#0000000&@29
+| +0#0000e05#a8a8a8255@1|"+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l| 
|f|d|c|=|2| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@34
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |d|e|f| |F|u|n|A|(|)|:| 
|s|t|r|i|n|g|-@40
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |d|e|f| |F|u|n|B|(|)|:| 
|s|t|r|i|n|g|-@40
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|u|n|C|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| 
|F|u|n|D|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|A|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|B|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|C|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1>e+0#af5f00255#ffffff0|c|h|o| 
+0#0000000&|F|u|n|D|(+0#e000e06&|)| +0#0000000&@61
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|4|0|,|1| @9|A|l@1| 
diff --git a/runtime/syntax/testdir/input/vim_ex_def_fold.vim 
b/runtime/syntax/testdir/input/vim_ex_def_fold.vim
index 865fc5a91..3326075a3 100644
--- a/runtime/syntax/testdir/input/vim_ex_def_fold.vim
+++ b/runtime/syntax/testdir/input/vim_ex_def_fold.vim
@@ -108,3 +108,23 @@ def Foo()
   "useless string"
 enddef
 
+
+" fold-region ending
+
+def Foo()
+  # enddef
+enddef
+
+def Foo()
+  echo "enddef"
+enddef
+
+def Foo()
+  let x =<< END
+    endfunction
+  END
+enddef
+
+:def Foo()
+:enddef
+
diff --git a/runtime/syntax/testdir/input/vim_ex_def_nested.vim 
b/runtime/syntax/testdir/input/vim_ex_def_nested.vim
new file mode 100644
index 000000000..008c41520
--- /dev/null
+++ b/runtime/syntax/testdir/input/vim_ex_def_nested.vim
@@ -0,0 +1,20 @@
+vim9script
+# Vim9 :def command (nested)
+
+class Test
+    const name: string
+
+    def new()
+       def Name(): string
+           function GiveName()
+               return "any"
+           endfunction
+
+           return GiveName()
+       enddef
+
+       this.name = Name()
+    enddef
+endclass
+
+echo Test.new()
diff --git a/runtime/syntax/testdir/input/vim_ex_def_nested_fold.vim 
b/runtime/syntax/testdir/input/vim_ex_def_nested_fold.vim
new file mode 100644
index 000000000..601f55356
--- /dev/null
+++ b/runtime/syntax/testdir/input/vim_ex_def_nested_fold.vim
@@ -0,0 +1,22 @@
+vim9script
+# Vim9 :def command (nested)
+# VIM_TEST_SETUP let g:vimsyn_folding = 'f'
+# VIM_TEST_SETUP setl fdc=2 fdm=syntax
+
+class Test
+    const name: string
+
+    def new()
+       def Name(): string
+           function GiveName()
+               return "any"
+           endfunction
+
+           return GiveName()
+       enddef
+
+       this.name = Name()
+    enddef
+endclass
+
+echo Test.new()
diff --git a/runtime/syntax/testdir/input/vim_ex_function_fold.vim 
b/runtime/syntax/testdir/input/vim_ex_function_fold.vim
index f9d9bee47..dd260ca45 100644
--- a/runtime/syntax/testdir/input/vim_ex_function_fold.vim
+++ b/runtime/syntax/testdir/input/vim_ex_function_fold.vim
@@ -181,3 +181,43 @@ delfunction foo.bar
 delfunction! Foo
 delfunction foo.bar
 
+
+" fold-region ending
+
+function Foo()
+  " endfunction
+endfunction
+
+function Foo()
+  echo "endfunction"
+endfunction
+
+function Foo()
+  let x =<< END
+    endfunction
+  END
+
+endfunction
+
+function Foo()
+  append
+    endfunction
+.
+endfunction
+
+function Foo()
+  change
+    endfunction
+.
+
+endfunction
+
+function Foo()
+  insert
+    endfunction
+.
+endfunction
+
+:function Foo()
+:endfunction
+
diff --git a/runtime/syntax/testdir/input/vim_ex_function_nested.vim 
b/runtime/syntax/testdir/input/vim_ex_function_nested.vim
new file mode 100644
index 000000000..749b57238
--- /dev/null
+++ b/runtime/syntax/testdir/input/vim_ex_function_nested.vim
@@ -0,0 +1,38 @@
+" Vim :def and :function commands (nested)
+
+def FunA(): string
+    def DoFunA(): string
+       return "."
+    enddef
+
+    return DoFunA()
+enddef
+
+def FunB(): string
+    function DoFunB()
+       return ".."
+    endfunction
+
+    return DoFunB()
+enddef
+
+function FunC()
+    def DoFunC(): string
+       return "..."
+    enddef
+
+    return DoFunC()
+endfunction
+
+function FunD()
+    function DoFunD()
+       return "...."
+    endfunction
+
+    return DoFunD()
+endfunction
+
+echo FunA()
+echo FunB()
+echo FunC()
+echo FunD()
diff --git a/runtime/syntax/testdir/input/vim_ex_function_nested_fold.vim 
b/runtime/syntax/testdir/input/vim_ex_function_nested_fold.vim
new file mode 100644
index 000000000..d966ef386
--- /dev/null
+++ b/runtime/syntax/testdir/input/vim_ex_function_nested_fold.vim
@@ -0,0 +1,40 @@
+" Vim :def and :function commands (nested)
+" VIM_TEST_SETUP let g:vimsyn_folding = 'f'
+" VIM_TEST_SETUP setl fdc=2 fdm=syntax
+
+def FunA(): string
+    def DoFunA(): string
+       return "."
+    enddef
+
+    return DoFunA()
+enddef
+
+def FunB(): string
+    function DoFunB()
+       return ".."
+    endfunction
+
+    return DoFunB()
+enddef
+
+function FunC()
+    def DoFunC(): string
+       return "..."
+    enddef
+
+    return DoFunC()
+endfunction
+
+function FunD()
+    function DoFunD()
+       return "...."
+    endfunction
+
+    return DoFunD()
+endfunction
+
+echo FunA()
+echo FunB()
+echo FunC()
+echo FunD()
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
index c5f6b6904..02d6dde67 100644
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -228,9 +228,9 @@ syn cluster vimExprList 
contains=vimEnvvar,vimFunc,vimFuncVar,vimNumber,vimOper,
 "   (buftype != nofile test avoids having append, change, insert show up in 
the command window)
 " =======================
 if &buftype != 'nofile'
- syn region vimInsert  matchgroup=vimCommand start="^[:        
]*\(\d\+\(,\d\+\)\=\)\=a\%[ppend]$"             matchgroup=vimCommand 
end="^\.$""
- syn region vimInsert  matchgroup=vimCommand start="^[:        
]*\(\d\+\(,\d\+\)\=\)\=c\%[hange]$"             matchgroup=vimCommand 
end="^\.$""
- syn region vimInsert  matchgroup=vimCommand start="^[:        
]*\(\d\+\(,\d\+\)\=\)\=i\%[nsert]$"             matchgroup=vimCommand 
end="^\.$""
+ syn region vimInsert  matchgroup=vimCommand start="^[:        
]*\(\d\+\(,\d\+\)\=\)\=a\%[ppend]$"             matchgroup=vimCommand 
end="^\.$" extend
+ syn region vimInsert  matchgroup=vimCommand start="^[:        
]*\(\d\+\(,\d\+\)\=\)\=c\%[hange]$"             matchgroup=vimCommand 
end="^\.$" extend
+ syn region vimInsert  matchgroup=vimCommand start="^[:        
]*\(\d\+\(,\d\+\)\=\)\=i\%[nsert]$"             matchgroup=vimCommand 
end="^\.$" extend
 endif
 
 " Behave! {{{2
@@ -281,12 +281,14 @@ if !exists("g:vimsyn_noerror") && 
!exists("g:vimsyn_noopererror")
  syn match     vimOperError    ")"
 endif
 
-" Functions : Tag is provided for those who wish to highlight tagged functions 
{{{2
+" Functions: Tag is provided for those who wish to highlight tagged functions 
{{{2
 " =========
 syn cluster    vimFuncList     
contains=vimFuncBang,vimFunctionError,vimFuncKey,vimFuncSID,Tag
 syn cluster    vimDefList      
contains=vimFuncBang,vimFunctionError,vimDefKey,vimFuncSID,Tag
-syn cluster    vimFuncBodyList 
contains=@vimCmdList,vimCmplxRepeat,vimComment,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimFuncVar,vimLetHereDoc,vimLineComment,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegion,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst
-syn cluster    vimDefBodyList  
contains=@vimCmdList,vimCmplxRepeat,vim9Comment,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimLetHereDoc,vim9LineComment,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegion,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst
+
+syn cluster    vimFuncBodyCommon       
contains=@vimCmdList,vimCmplxRepeat,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimLetHereDoc,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst,vimFuncFold
+syn cluster    vimFuncBodyList 
contains=@vimFuncBodyCommon,vimComment,vimLineComment,vimFuncVar,vimInsert
+syn cluster    vimDefBodyList  
contains=@vimFuncBodyCommon,vim9Comment,vim9LineComment
 
 syn region     vimFuncPattern  contained               matchgroup=vimOper 
start="/" end="$" contains=@vimSubstList
 syn match      vimFunction     "\<fu\%[nction]\>"      skipwhite 
nextgroup=vimCmdSep,vimComment,vimFuncPattern contains=vimFuncKey
@@ -321,9 +323,9 @@ syn match   vimEndfunction  "\<endf\%[unction]\>"
 syn match      vimEnddef       "\<enddef\>"
 
 if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f'
- syn region    vimFuncFold     
start="\<fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+\s*("
        end="\<endf\%[unction]\>" contains=vimFunction fold keepend transparent
- syn region    vimFuncFold     
start="\<def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\)\+("               
end="\<enddef\>"                contains=vimDef      fold keepend transparent
- syn region    vimFuncFold     start="\<def\s\+new\i\+("                       
        end="\<enddef\>"                contains=vimDef      fold keepend 
transparent
+ syn region    vimFuncFold     
start="^\s*:\=\s*fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+\s*("
        end="^\s*:\=\s*endf\%[unction]\>" contains=vimFunction fold keepend 
extend transparent
+ syn region    vimFuncFold     
start="^\s*:\=\s*def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\)\+("       
        end="^\s*:\=\s*enddef\>"          contains=vimDef      fold keepend 
extend transparent
+ syn region    vimFuncFold     start="^\s*:\=\s*def\s\+new\i\+("               
                        end="^\s*:\=\s*enddef\>"          contains=vimDef      
fold keepend extend transparent
 endif
 
 syn match      vimFuncVar   contained  "a:\%(\K\k*\|\d\+\)\>"
@@ -540,7 +542,7 @@ syn keyword vimUnlet        unl[et]         skipwhite 
nextgroup=vimUnletBang,vimUnletVars
 syn match      vimUnletBang    contained       "!"     skipwhite 
nextgroup=vimUnletVars
 syn region     vimUnletVars    contained       start="$\I\|\h" skip="
\s*\" end="$" end="|" contains=vimVar,vimEnvvar,vimContinue,vimString,vimNumber
 
-VimFoldh syn region vimLetHereDoc      matchgroup=vimLetHereDocStart 
start='=<<\s*\%(trim\s\+\%(eval\s\+\)\=\|eval\s\+\%(trim\s\+\)\=\)\=\z(\L\S*\)' 
matchgroup=vimLetHereDocStop end='^\s*\z1\s*$'
+VimFoldh syn region vimLetHereDoc      matchgroup=vimLetHereDocStart 
start='=<<\s*\%(trim\s\+\%(eval\s\+\)\=\|eval\s\+\%(trim\s\+\)\=\)\=\z(\L\S*\)' 
matchgroup=vimLetHereDocStop end='^\s*\z1\s*$' extend
 syn keyword    vimLet  var             skipwhite 
nextgroup=vimVar,vimFuncVar,vimLetHereDoc
 
 " For: {{{2

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1rw4qf-00ASmw-OG%40256bit.org.

Raspunde prin e-mail lui