patch 9.0.0379: cleaning up after writefile() is a hassle
Problem: Cleaning up after writefile() is a hassle.
Solution: Add the 'D' flag to defer deleting the written file. Very useful
in tests.
diff --git a/src/vim9expr.c b/src/vim9expr.c
index 18f29b6..a8d88a2 100644
--- a/src/vim9expr.c
+++ b/src/vim9expr.c
@@ -833,6 +833,14 @@
}
}
+ if (STRCMP(name, "writefile") == 0 && argcount > 2)
+ {
+ // May have the "D" flag, reserve a variable for a deferred
+ // function call.
+ if (get_defer_var_idx(cctx) == 0)
+ idx = -1;
+ }
+
if (idx >= 0)
res = generate_BCALL(cctx, idx, argcount, argcount_init == 1);
}