patch 8.0.1053: setline() does not work on startup
Problem: setline() does not work on startup. (Manuel Ortega)
Solution: Do not check for ml_mfp to be set for the current buffer.
(Christian Brabandt)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 2692de6..cf9c8d8 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -9885,7 +9885,10 @@
buf_T *curbuf_save;
int is_curbuf = buf == curbuf;
- if (buf == NULL || buf->b_ml.ml_mfp == NULL || lnum < 1)
+ /* When using the current buffer ml_mfp will be set if needed. Useful when
+ * setline() is used on startup. For other buffers the buffer must be
+ * loaded. */
+ if (buf == NULL || (!is_curbuf && buf->b_ml.ml_mfp == NULL) || lnum < 1)
{
rettv->vval.v_number = 1; /* FAIL */
return;