mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
Merge pull request #17647 from neovim/backport-16851-to-release-0.6
[Backport release-0.6] vim-patch:8.2.3952: first line not redrawn when adding lines to an empty buffer
This commit is contained in:
commit
be368a6f74
@ -3009,7 +3009,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;
|
||||
|
@ -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
|
||||
|
@ -1,23 +1,26 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
|
||||
local eq = helpers.eq
|
||||
local dedent = helpers.dedent
|
||||
local exec = helpers.exec
|
||||
local feed = helpers.feed
|
||||
local clear = helpers.clear
|
||||
local funcs = helpers.funcs
|
||||
local command = helpers.command
|
||||
local curbufmeths = helpers.curbufmeths
|
||||
|
||||
before_each(function()
|
||||
clear()
|
||||
curbufmeths.set_lines(0, 1, true, { 'foo', 'bar', 'baz' })
|
||||
end)
|
||||
|
||||
local buffer_contents = function()
|
||||
return curbufmeths.get_lines(0, -1, false)
|
||||
end
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
||||
local cmdtest = function(cmd, prep, ret1)
|
||||
describe(':' .. cmd, function()
|
||||
before_each(function()
|
||||
clear()
|
||||
curbufmeths.set_lines(0, 1, true, { 'foo', 'bar', 'baz' })
|
||||
end)
|
||||
|
||||
local buffer_contents = function()
|
||||
return curbufmeths.get_lines(0, -1, false)
|
||||
end
|
||||
|
||||
it(cmd .. 's' .. prep .. ' the current line by default', function()
|
||||
command(cmd .. '\nabc\ndef\n')
|
||||
eq(ret1, buffer_contents())
|
||||
@ -52,3 +55,52 @@ end
|
||||
cmdtest('insert', ' before', { 'abc', 'def', 'foo', 'bar', 'baz' })
|
||||
cmdtest('append', ' after', { 'foo', 'abc', 'def', 'bar', 'baz' })
|
||||
cmdtest('change', '', { 'abc', 'def', 'bar', 'baz' })
|
||||
|
||||
describe('the first line is redrawn correctly after inserting text in an empty buffer', function()
|
||||
local screen
|
||||
before_each(function()
|
||||
clear()
|
||||
screen = Screen.new(20, 8)
|
||||
screen:set_default_attr_ids({
|
||||
[1] = {bold = true, foreground = Screen.colors.Blue},
|
||||
[2] = {bold = true, reverse = true},
|
||||
})
|
||||
screen:attach()
|
||||
end)
|
||||
|
||||
it('using :append', function()
|
||||
exec(dedent([[
|
||||
append
|
||||
aaaaa
|
||||
bbbbb
|
||||
.]]))
|
||||
screen:expect([[
|
||||
aaaaa |
|
||||
^bbbbb |
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
it('using :insert', function()
|
||||
exec(dedent([[
|
||||
insert
|
||||
aaaaa
|
||||
bbbbb
|
||||
.]]))
|
||||
screen:expect([[
|
||||
aaaaa |
|
||||
^bbbbb |
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user