mirror of
https://github.com/neovim/neovim.git
synced 2025-01-01 17:23:36 -07:00
Merge #8672 'test: nvim_buf_attach after delay'
This commit is contained in:
commit
bd51a0cd04
@ -1,9 +1,11 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
|
local clear = helpers.clear
|
||||||
local eq, ok = helpers.eq, helpers.ok
|
local eq, ok = helpers.eq, helpers.ok
|
||||||
local buffer, command, eval, nvim, next_msg = helpers.buffer,
|
local buffer, command, eval, nvim, next_msg = helpers.buffer,
|
||||||
helpers.command, helpers.eval, helpers.nvim, helpers.next_msg
|
helpers.command, helpers.eval, helpers.nvim, helpers.next_msg
|
||||||
local expect_err = helpers.expect_err
|
local expect_err = helpers.expect_err
|
||||||
local nvim_prog = helpers.nvim_prog
|
local nvim_prog = helpers.nvim_prog
|
||||||
|
local sleep = helpers.sleep
|
||||||
local write_file = helpers.write_file
|
local write_file = helpers.write_file
|
||||||
|
|
||||||
local origlines = {"original line 1",
|
local origlines = {"original line 1",
|
||||||
@ -51,7 +53,7 @@ local function editoriginal(activate, lines)
|
|||||||
lines = origlines
|
lines = origlines
|
||||||
end
|
end
|
||||||
-- load up the file with the correct contents
|
-- load up the file with the correct contents
|
||||||
helpers.clear()
|
clear()
|
||||||
return open(activate, lines)
|
return open(activate, lines)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -435,8 +437,7 @@ describe('API: buffer events:', function()
|
|||||||
expectn('nvim_buf_changedtick_event', {b3, tick3})
|
expectn('nvim_buf_changedtick_event', {b3, tick3})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not get confused if enabled/disabled many times',
|
it('does not get confused if enabled/disabled many times', function()
|
||||||
function()
|
|
||||||
local channel = nvim('get_api_info')[1]
|
local channel = nvim('get_api_info')[1]
|
||||||
local b, tick = editoriginal(false)
|
local b, tick = editoriginal(false)
|
||||||
|
|
||||||
@ -462,7 +463,7 @@ describe('API: buffer events:', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('can notify several channels at once', function()
|
it('can notify several channels at once', function()
|
||||||
helpers.clear()
|
clear()
|
||||||
|
|
||||||
-- create several new sessions, in addition to our main API
|
-- create several new sessions, in addition to our main API
|
||||||
local sessions = {}
|
local sessions = {}
|
||||||
@ -482,7 +483,7 @@ describe('API: buffer events:', function()
|
|||||||
|
|
||||||
local function wantn(sessionid, name, args)
|
local function wantn(sessionid, name, args)
|
||||||
local session = sessions[sessionid]
|
local session = sessions[sessionid]
|
||||||
eq({'notification', name, args}, session:next_message())
|
eq({'notification', name, args}, session:next_message(10000))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Edit a new file, but don't enable buffer events.
|
-- Edit a new file, but don't enable buffer events.
|
||||||
@ -710,10 +711,9 @@ describe('API: buffer events:', function()
|
|||||||
expectn('nvim_buf_lines_event', {b, tick, 0, 1, {'AA'}, false})
|
expectn('nvim_buf_lines_event', {b, tick, 0, 1, {'AA'}, false})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('detaches if the buffer is unloaded/deleted/wiped',
|
it('detaches if the buffer is unloaded/deleted/wiped', function()
|
||||||
function()
|
|
||||||
-- start with a blank nvim
|
-- start with a blank nvim
|
||||||
helpers.clear()
|
clear()
|
||||||
-- need to make a new window with a buffer because :bunload doesn't let you
|
-- need to make a new window with a buffer because :bunload doesn't let you
|
||||||
-- unload the last buffer
|
-- unload the last buffer
|
||||||
for _, cmd in ipairs({'bunload', 'bdelete', 'bwipeout'}) do
|
for _, cmd in ipairs({'bunload', 'bdelete', 'bwipeout'}) do
|
||||||
@ -729,23 +729,36 @@ describe('API: buffer events:', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not send the buffer content if not requested', function()
|
it('does not send the buffer content if not requested', function()
|
||||||
helpers.clear()
|
clear()
|
||||||
local b, tick = editoriginal(false)
|
local b, tick = editoriginal(false)
|
||||||
ok(buffer('attach', b, false, {}))
|
ok(buffer('attach', b, false, {}))
|
||||||
expectn('nvim_buf_changedtick_event', {b, tick})
|
expectn('nvim_buf_changedtick_event', {b, tick})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('returns a proper error on nonempty options dict', function()
|
it('returns a proper error on nonempty options dict', function()
|
||||||
helpers.clear()
|
clear()
|
||||||
local b = editoriginal(false)
|
local b = editoriginal(false)
|
||||||
expect_err("dict isn't empty", buffer, 'attach', b, false, {builtin="asfd"})
|
expect_err("dict isn't empty", buffer, 'attach', b, false, {builtin="asfd"})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('nvim_buf_attach returns response after delay #8634', function()
|
||||||
|
clear()
|
||||||
|
sleep(250)
|
||||||
|
-- response
|
||||||
|
eq(true, helpers.request('nvim_buf_attach', 0, false, {}))
|
||||||
|
-- notification
|
||||||
|
eq({
|
||||||
|
[1] = 'notification',
|
||||||
|
[2] = 'nvim_buf_changedtick_event',
|
||||||
|
[3] = {
|
||||||
|
[1] = { id = 1 },
|
||||||
|
[2] = 2 }, }, next_msg())
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('API: buffer events:', function()
|
describe('API: buffer events:', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
helpers.clear()
|
clear()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function lines_subset(first, second)
|
local function lines_subset(first, second)
|
||||||
|
Loading…
Reference in New Issue
Block a user