diff options
| -rw-r--r-- | src/nvim/ex_docmd.c | 11 | ||||
| -rw-r--r-- | src/nvim/testdir/test_nested_function.vim | 21 | ||||
| -rw-r--r-- | src/nvim/version.c | 2 | 
3 files changed, 28 insertions, 6 deletions
| diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 1a766821a9..29788a9865 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -340,12 +340,13 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline,    msg_list = &private_msg_list;    private_msg_list = NULL; -  /* It's possible to create an endless loop with ":execute", catch that -   * here.  The value of 200 allows nested function calls, ":source", etc. */ -  if (call_depth == 200) { +  // It's possible to create an endless loop with ":execute", catch that +  // here.  The value of 200 allows nested function calls, ":source", etc. +  // Allow 200 or 'maxfuncdepth', whatever is larger. +  if (call_depth >= 200 && call_depth >= p_mfd) {      EMSG(_("E169: Command too recursive")); -    /* When converting to an exception, we do not include the command name -     * since this is not an error of the specific command. */ +    // When converting to an exception, we do not include the command name +    // since this is not an error of the specific command.      do_errthrow((struct condstack *)NULL, (char_u *)NULL);      msg_list = saved_msg_list;      return FAIL; diff --git a/src/nvim/testdir/test_nested_function.vim b/src/nvim/testdir/test_nested_function.vim index 7e301ed33e..afaaea6ceb 100644 --- a/src/nvim/testdir/test_nested_function.vim +++ b/src/nvim/testdir/test_nested_function.vim @@ -40,3 +40,24 @@ func Test_nested_argument()    delfunc g:X    unlet g:Y  endfunc + +func Recurse(count) +  if a:count > 0 +    call Recurse(a:count - 1) +  endif +endfunc + +func Test_max_nesting() +  let call_depth_here = 2 +  let ex_depth_here = 5 +  set mfd& + +  call Recurse(99 - call_depth_here) +  call assert_fails('call Recurse(' . (100 - call_depth_here) . ')', 'E132:') + +  set mfd=210 +  call Recurse(209 - ex_depth_here) +  call assert_fails('call Recurse(' . (210 - ex_depth_here) . ')', 'E169:') + +  set mfd& +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 9305618eae..fd2f1fd212 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -815,7 +815,7 @@ static const int included_patches[] = {    // 140,    // 139 NA    // 138 NA -  // 137, +  137,    136,    135,    134, | 
