vim-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)
9d954207e2
This commit is contained in:
Daniel Hahler
2019-06-18 00:09:45 +02:00
parent 9485061baa
commit 8db93d0d83
3 changed files with 29 additions and 5 deletions

View File

@@ -14854,7 +14854,10 @@ static void set_buffer_lines(buf_T *buf, linenr_T lnum, typval_T *lines,
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;
}