On Mon, Sep 4, 2017 at 3:01 AM, Christian Brabandt <[email protected]>
wrote:
>
> On Mo, 04 Sep 2017, Manuel Ortega wrote:
>
> > 8.0.1039 broke setline(). I know this by bisection. To reproduce:
> >
> > Make a file, testvimrc, that contains one line: "source foo".
> >
> > Create the file "foo", and let it contain only the following:
> >
> > call setline(1, "Hello There")
> >
> > To show the bug, do: vim -u testvimrc -u NONE -N
> >
> > Expected behavior, which was also the actual behavior before 8.0.1039:
> I see a
> > new buffer with "Hello There" on the first line.
> >
> > Actual behavior: after 8.0.1039: I see no text whatsoever in the buffer.
> >
> > This is on macOS 10.12.6.
>
> I see the problem. There is a new check for buf->b_ml.ml_mfp == NULL in
> set_buffer_lines that wasn't there previously and this was no problem
> before, because ml_replace would open the buffer if ml_mfp would be
> null. I think we can safely change this check to:
>
> diff --git a/src/evalfunc.c b/src/evalfunc.c
> index 2692de61f..e68e0b00e 100644
> --- a/src/evalfunc.c
> +++ b/src/evalfunc.c
> @@ -9885,7 +9885,7 @@ set_buffer_lines(buf_T *buf, linenr_T lnum, typval_T
> *lines, typval_T *rettv)
> buf_T *curbuf_save;
> int is_curbuf = buf == curbuf;
>
> - if (buf == NULL || buf->b_ml.ml_mfp == NULL || lnum < 1)
> + if (buf == NULL || (buf->b_ml.ml_mfp == NULL && !is_curbuf)|| lnum <
> 1)
> {
> rettv->vval.v_number = 1; /* FAIL */
> return;
>
>
> or perhaps even completely remove the check. Not sure if this however
> will break in some situations, but at least I could not break it using
>
> :call setbufline(5, 1, 'foobar')
>
> in the startupfile (when buffer number 5 does not exist yet.
>
I've tried this out over the last few hours and it seems to have restored
the old behavior. I am, however, unqualified to say whether it's the Right
Fix.
-Manny
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.