From 09cbd6769b737e9de88e9885f19c2bd0f5fa5795 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Tue, 27 Aug 2019 23:50:55 +0200 Subject: vim-patch:8.1.1932: ml_get errors after append() #10866 Problem: Ml_get errors after using append(). (Alex Genco) Solution: Do not update the cursor twice. https://github.com/vim/vim/commit/d20070274c47668560e02db184e1f8e456c3c326 fix #10847 --- src/nvim/eval.c | 8 +++++++- src/nvim/testdir/test_functions.vim | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 879600b9b1..d883b53ed2 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -15217,8 +15217,14 @@ static void set_buffer_lines(buf_T *buf, linenr_T lnum_arg, bool append, if (added > 0) { 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; } } diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index fe3b8bef6e..6c3d944ad5 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -592,6 +592,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' -- cgit