patch 8.1.1932: ml_get errors after using append()
Problem: Ml_get errors after using append(). (Alex Genco)
Solution: Do not update the cursor twice. (closes #1737)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 498e87f..882bf09 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -1440,8 +1440,14 @@
tabpage_T *tp;
appended_lines_mark(append_lnum, added);
+
+ // Only adjust the cursor for buffers other than the current, unless it
+ // is the current window. For curbuf and other windows it has been
+ // done in mark_adjust_internal().
FOR_ALL_TAB_WINDOWS(tp, wp)
- if (wp->w_buffer == buf && wp->w_cursor.lnum > append_lnum)
+ if (wp->w_buffer == buf
+ && (wp->w_buffer != curbuf || wp == curwin)
+ && wp->w_cursor.lnum > append_lnum)
wp->w_cursor.lnum += added;
check_cursor_col();
update_topline();
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 027700b..1352eaa 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -705,6 +705,15 @@
set complete&
endfunc
+func Test_append()
+ enew!
+ split
+ call append(0, ["foo"])
+ split
+ only
+ undo
+endfunc
+
func Test_getbufvar()
let bnr = bufnr('%')
let b:var_num = '1234'
diff --git a/src/version.c b/src/version.c
index 9c8ff70..412ae92 100644
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1932,
+/**/
1931,
/**/
1930,