patch 8.2.2070: can't get the exit value in VimLeave(Pre) autocommands
Problem: Can't get the exit value in VimLeave or VimLeavePre autocommands.
Solution: Add v:exiting like in Neovim. (Yegappan Lakshmanan, closes #7395)
diff --git a/src/main.c b/src/main.c
index e3ce9e4..1b7811a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1505,7 +1505,8 @@
/*
- * Exit properly.
+ * Exit properly. This is the only way to exit Vim after startup has
+ * succeeded. We are certain to exit here, no way to abort it.
*/
void
getout(int exitval)
@@ -1521,6 +1522,11 @@
if (exmode_active)
exitval += ex_exitval;
+#ifdef FEAT_EVAL
+ set_vim_var_type(VV_EXITING, VAR_NUMBER);
+ set_vim_var_nr(VV_EXITING, exitval);
+#endif
+
// Position the cursor on the last screen line, below all the text
#ifdef FEAT_GUI
if (!gui.in_use)