diff src/userfunc.c @ 18104:e59ff7b5d7a7 v8.1.2047

patch 8.1.2047: cannot check the current state Commit: https://github.com/vim/vim/commit/0e57dd859ecb1e8a3b91509d2f4343e839340eb8 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Sep 16 22:56:03 2019 +0200 patch 8.1.2047: cannot check the current state Problem: Cannot check the current state. Solution: Add the state() function.
author Bram Moolenaar <Bram@vim.org>
date Mon, 16 Sep 2019 23:00:04 +0200
parents 6249953b0609
children fe5afdc03bd2
line wrap: on
line diff
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -1447,6 +1447,14 @@ func_call(
     return r;
 }
 
+static int callback_depth = 0;
+
+    int
+get_callback_depth(void)
+{
+    return callback_depth;
+}
+
 /*
  * Invoke call_func() with a callback.
  */
@@ -1460,12 +1468,15 @@ call_callback(
 				// PLUS ONE elements!
 {
     funcexe_T	funcexe;
+    int		ret;
 
     vim_memset(&funcexe, 0, sizeof(funcexe));
     funcexe.evaluate = TRUE;
     funcexe.partial = callback->cb_partial;
-    return call_func(callback->cb_name, len, rettv, argcount, argvars,
-								     &funcexe);
+    ++callback_depth;
+    ret = call_func(callback->cb_name, len, rettv, argcount, argvars, &funcexe);
+    --callback_depth;
+    return ret;
 }
 
 /*