summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-09-21 16:59:45 +0200
committerBram Moolenaar <Bram@vim.org>2018-09-21 16:59:45 +0200
commit9cea87c5775948a35098f3602746c20ecf95dbcd (patch)
treee3d94740a9c2b64149479c1d03b1d07d3e4a65e6 /src
parente76d7a63dfe916c321e248fbfc97bd948d6fbabb (diff)
patch 8.1.0425: ml_get error and crash with appendbufline()v8.1.0425
Problem: ml_get error and crash with appendbufline(). (Masashi Iizuka) Solution: Set per-window buffer info. (Hirohito Higashi, closes #3455)
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c6
-rw-r--r--src/testdir/test_bufline.vim27
-rw-r--r--src/version.c2
3 files changed, 35 insertions, 0 deletions
diff --git a/src/buffer.c b/src/buffer.c
index b536be64bf..a4afe132e0 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -428,7 +428,10 @@ can_unload_buffer(buf_T *buf)
FOR_ALL_WINDOWS(wp)
if (wp->w_buffer == buf)
+ {
can_unload = FALSE;
+ break;
+ }
}
if (!can_unload)
EMSG(_("E937: Attempt to delete a buffer that is in use"));
@@ -1742,6 +1745,9 @@ enter_buffer(buf_T *buf)
/* mark cursor position as being invalid */
curwin->w_valid = 0;
+ buflist_setfpos(curbuf, curwin, curbuf->b_last_cursor.lnum,
+ curbuf->b_last_cursor.col, TRUE);
+
/* Make sure the buffer is loaded. */
if (curbuf->b_ml.ml_mfp == NULL) /* need to load the file */
{
diff --git a/src/testdir/test_bufline.vim b/src/testdir/test_bufline.vim
index 1f83e8b776..524144d5b9 100644
--- a/src/testdir/test_bufline.vim
+++ b/src/testdir/test_bufline.vim
@@ -91,6 +91,33 @@ func Test_appendbufline()
exe "bwipe! " . b
endfunc
+func Test_appendbufline_no_E315()
+ let after = [
+ \ 'set stl=%f ls=2',
+ \ 'new',
+ \ 'let buf = bufnr("%")',
+ \ 'quit',
+ \ 'vsp',
+ \ 'exec "buffer" buf',
+ \ 'wincmd w',
+ \ 'call appendbufline(buf, 0, "abc")',
+ \ 'redraw',
+ \ 'while getbufline(buf, 1)[0] =~ "^\\s*$"',
+ \ ' sleep 10m',
+ \ 'endwhile',
+ \ 'au VimLeavePre * call writefile([v:errmsg], "Xerror")',
+ \ 'au VimLeavePre * call writefile(["done"], "Xdone")',
+ \ 'qall!',
+ \ ]
+ if !RunVim([], after, '--clean')
+ return
+ endif
+ call assert_notmatch("^E315:", readfile("Xerror")[0])
+ call assert_equal("done", readfile("Xdone")[0])
+ call delete("Xerror")
+ call delete("Xdone")
+endfunc
+
func Test_deletebufline()
new
let b = bufnr('%')
diff --git a/src/version.c b/src/version.c
index dd764ea3c4..22cc075d00 100644
--- a/src/version.c
+++ b/src/version.c
@@ -795,6 +795,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 425,
+/**/
424,
/**/
423,