mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
parent
70626e6a1e
commit
40911e435e
@ -1239,9 +1239,7 @@ static void refresh_screen(Terminal *term, buf_T *buf)
|
||||
|
||||
int change_start = row_to_linenr(term, term->invalid_start);
|
||||
int change_end = change_start + changed;
|
||||
changed_lines(change_start, 0, change_end, added,
|
||||
// Don't send nvim_buf_lines_event for :terminal buffer.
|
||||
false);
|
||||
changed_lines(change_start, 0, change_end, added, true);
|
||||
term->invalid_start = INT_MAX;
|
||||
term->invalid_end = -1;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ local eq, ok = helpers.eq, helpers.ok
|
||||
local buffer, command, eval, nvim, next_msg = helpers.buffer,
|
||||
helpers.command, helpers.eval, helpers.nvim, helpers.next_msg
|
||||
local expect_err = helpers.expect_err
|
||||
local nvim_prog = helpers.nvim_prog
|
||||
local write_file = helpers.write_file
|
||||
|
||||
local origlines = {"original line 1",
|
||||
@ -741,3 +742,88 @@ describe('API: buffer events:', function()
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
describe('API: buffer events:', function()
|
||||
before_each(function()
|
||||
helpers.clear()
|
||||
end)
|
||||
|
||||
local function lines_subset(first, second)
|
||||
for i = 1,#first do
|
||||
if first[i] ~= second[i] then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function lines_equal(f, s)
|
||||
return lines_subset(f, s) and lines_subset(s, f)
|
||||
end
|
||||
|
||||
local function assert_match_somewhere(expected_lines, buffer_lines)
|
||||
local msg = next_msg()
|
||||
|
||||
while(msg ~= nil) do
|
||||
local event = msg[2]
|
||||
if event == 'nvim_buf_lines_event' then
|
||||
local args = msg[3]
|
||||
local starts = args[3]
|
||||
local newlines = args[5]
|
||||
|
||||
-- Size of the contained nvim instance is 23 lines, this might change
|
||||
-- with the test setup. Note updates are continguous.
|
||||
assert(#newlines <= 23)
|
||||
|
||||
for i = 1,#newlines do
|
||||
buffer_lines[starts + i] = newlines[i]
|
||||
end
|
||||
-- we don't compare the msg area of the embedded nvim, it's too flakey
|
||||
buffer_lines[23] = nil
|
||||
|
||||
if lines_equal(buffer_lines, expected_lines) then
|
||||
-- OK
|
||||
return
|
||||
end
|
||||
end
|
||||
msg = next_msg()
|
||||
end
|
||||
assert(false, 'did not match/receive expected nvim_buf_lines_event lines')
|
||||
end
|
||||
|
||||
it('when :terminal lines change', function()
|
||||
local buffer_lines = {}
|
||||
local expected_lines = {}
|
||||
command('terminal "'..nvim_prog..'" -u NONE -i NONE -n -c "set shortmess+=A"')
|
||||
local b = nvim('get_current_buf')
|
||||
ok(buffer('attach', b, true, {}))
|
||||
|
||||
for _ = 1,22 do
|
||||
table.insert(expected_lines,'~')
|
||||
end
|
||||
expected_lines[1] = ''
|
||||
expected_lines[22] = ('tmp_terminal_nvim'..(' '):rep(45)
|
||||
..'0,0-1 All')
|
||||
|
||||
sendkeys('i:e tmp_terminal_nvim<Enter>')
|
||||
assert_match_somewhere(expected_lines, buffer_lines)
|
||||
|
||||
expected_lines[1] = 'Blarg'
|
||||
expected_lines[22] = ('tmp_terminal_nvim [+]'..(' '):rep(41)
|
||||
..'1,6 All')
|
||||
|
||||
sendkeys('iBlarg')
|
||||
assert_match_somewhere(expected_lines, buffer_lines)
|
||||
|
||||
for i = 1,21 do
|
||||
expected_lines[i] = 'xyz'
|
||||
end
|
||||
expected_lines[22] = ('tmp_terminal_nvim [+]'..(' '):rep(41)
|
||||
..'31,4 Bot')
|
||||
|
||||
local s = string.rep('\nxyz', 30)
|
||||
sendkeys(s)
|
||||
assert_match_somewhere(expected_lines, buffer_lines)
|
||||
end)
|
||||
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user