changeset 17871:521ce0d887e5 v8.1.1932

patch 8.1.1932: ml_get errors after using append() Commit: https://github.com/vim/vim/commit/d20070274c47668560e02db184e1f8e456c3c326 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 27 21:56:06 2019 +0200 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 https://github.com/vim/vim/issues/1737)
author Bram Moolenaar <Bram@vim.org>
date Tue, 27 Aug 2019 22:00:04 +0200
parents ff2ef3e73a19
children a4a0f826d4d7
files src/evalfunc.c src/testdir/test_functions.vim src/version.c
diffstat 3 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -1440,8 +1440,14 @@ set_buffer_lines(
 	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();
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -705,6 +705,15 @@ func Test_mode()
   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'
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1932,
+/**/
     1931,
 /**/
     1930,