aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2021-12-31 22:20:31 +0800
committerzeertzjq <zeertzjq@outlook.com>2021-12-31 22:20:31 +0800
commitba7b30080fe933709269288338d96187f06eaf08 (patch)
tree7a7adaafae21d2eea7678e95c983de2eb9a29f8a /src
parent991e872d800dbd983d57e4768734cefb13503ee7 (diff)
downloadrneovim-ba7b30080fe933709269288338d96187f06eaf08.tar.gz
rneovim-ba7b30080fe933709269288338d96187f06eaf08.tar.bz2
rneovim-ba7b30080fe933709269288338d96187f06eaf08.zip
vim-patch:8.2.3952: first line not redrawn when adding lines to an empty buffer
Problem: First line not redrawn when adding lines to an empty buffer. Solution: Adjust the argument to appended_lines(). (closes vim/vim#9439, closes vim/vim#9438) https://github.com/vim/vim/commit/1fa3de1ce806ba18ebcc00c6d9a0678a84735463
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_cmds.c7
-rw-r--r--src/nvim/testdir/test_excmd.vim44
2 files changed, 50 insertions, 1 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index cc5ab1b554..95390b1a70 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -3006,7 +3006,12 @@ void ex_append(exarg_T *eap)
did_undo = true;
ml_append(lnum, theline, (colnr_T)0, false);
- appended_lines_mark(lnum + (empty ? 1 : 0), 1L);
+ if (empty) {
+ // there are no marks below the inserted lines
+ appended_lines(lnum, 1L);
+ } else {
+ appended_lines_mark(lnum, 1L);
+ }
xfree(theline);
++lnum;
diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim
index 2d01cbba83..1c053c824f 100644
--- a/src/nvim/testdir/test_excmd.vim
+++ b/src/nvim/testdir/test_excmd.vim
@@ -1,6 +1,8 @@
" Tests for various Ex commands.
source check.vim
+source shared.vim
+source term_util.vim
func Test_ex_delete()
new
@@ -122,6 +124,27 @@ func Test_append_cmd()
close!
endfunc
+func Test_append_cmd_empty_buf()
+ CheckRunVimInTerminal
+ let lines =<< trim END
+ func Timer(timer)
+ append
+ aaaaa
+ bbbbb
+ .
+ endfunc
+ call timer_start(10, 'Timer')
+ END
+ call writefile(lines, 'Xtest_append_cmd_empty_buf')
+ let buf = RunVimInTerminal('-S Xtest_append_cmd_empty_buf', {'rows': 6})
+ call WaitForAssert({-> assert_equal('bbbbb', term_getline(buf, 2))})
+ call WaitForAssert({-> assert_equal('aaaaa', term_getline(buf, 1))})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('Xtest_append_cmd_empty_buf')
+endfunc
+
" Test for the :insert command
func Test_insert_cmd()
set noautoindent " test assumes noautoindent, but it's on by default in Nvim
@@ -151,6 +174,27 @@ func Test_insert_cmd()
close!
endfunc
+func Test_insert_cmd_empty_buf()
+ CheckRunVimInTerminal
+ let lines =<< trim END
+ func Timer(timer)
+ insert
+ aaaaa
+ bbbbb
+ .
+ endfunc
+ call timer_start(10, 'Timer')
+ END
+ call writefile(lines, 'Xtest_insert_cmd_empty_buf')
+ let buf = RunVimInTerminal('-S Xtest_insert_cmd_empty_buf', {'rows': 6})
+ call WaitForAssert({-> assert_equal('bbbbb', term_getline(buf, 2))})
+ call WaitForAssert({-> assert_equal('aaaaa', term_getline(buf, 1))})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('Xtest_insert_cmd_empty_buf')
+endfunc
+
" Test for the :change command
func Test_change_cmd()
set noautoindent " test assumes noautoindent, but it's on by default in Nvim