aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/vim_spec.lua3
-rw-r--r--test/functional/autocmd/autocmd_spec.lua11
-rw-r--r--test/functional/core/startup_spec.lua5
-rw-r--r--test/functional/eval/system_spec.lua31
-rw-r--r--test/functional/ex_cmds/make_spec.lua44
-rw-r--r--test/functional/ex_cmds/source_spec.lua25
-rw-r--r--test/functional/fixtures/fake-lsp-server.lua17
-rw-r--r--test/functional/helpers.lua14
-rw-r--r--test/functional/legacy/memory_usage_spec.lua32
-rw-r--r--test/functional/lua/buffer_updates_spec.lua33
-rw-r--r--test/functional/lua/vim_spec.lua248
-rw-r--r--test/functional/plugin/lsp_spec.lua162
-rw-r--r--test/functional/provider/clipboard_spec.lua14
-rw-r--r--test/functional/ui/tabline_spec.lua43
-rw-r--r--test/unit/eval/typval_spec.lua2
-rw-r--r--test/unit/marktree_spec.lua15
16 files changed, 625 insertions, 74 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 0c0f610401..91d2745130 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -2003,6 +2003,7 @@ describe('API', function()
it('should have information about window options', function()
eq({
+ allows_duplicates = true,
commalist = false;
default = "";
flaglist = false;
@@ -2020,6 +2021,7 @@ describe('API', function()
it('should have information about buffer options', function()
eq({
+ allows_duplicates = true,
commalist = false,
default = "",
flaglist = false,
@@ -2041,6 +2043,7 @@ describe('API', function()
eq(false, meths.get_option'showcmd')
eq({
+ allows_duplicates = true,
commalist = false,
default = true,
flaglist = false,
diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua
index e62d3bb66b..93d71a9e45 100644
--- a/test/functional/autocmd/autocmd_spec.lua
+++ b/test/functional/autocmd/autocmd_spec.lua
@@ -101,6 +101,17 @@ describe('autocmd', function()
}, eval('g:evs'))
end)
+ it('WinClosed from root directory', function()
+ command('cd /')
+ command('let g:evs = []')
+ command('autocmd WinClosed * :call add(g:evs, ["WinClosed", expand("<afile>")])')
+ command('new')
+ command('close')
+ eq({
+ {'WinClosed', '1001'},
+ }, eval('g:evs'))
+ end)
+
it('v:vim_did_enter is 1 after VimEnter', function()
eq(1, eval('v:vim_did_enter'))
end)
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index 658dfbda60..a70b94c0e9 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -443,10 +443,7 @@ describe('user config init', function()
before_each(function()
rmdir(xhome)
- -- TODO, make mkdir_p helper
- mkdir(xhome)
- mkdir(xconfig)
- mkdir(xconfig .. pathsep .. 'nvim')
+ mkdir_p(xconfig .. pathsep .. 'nvim')
write_file(init_lua_path, [[
vim.g.lua_rc = 1
diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua
index 8b18eff451..c374baf695 100644
--- a/test/functional/eval/system_spec.lua
+++ b/test/functional/eval/system_spec.lua
@@ -174,6 +174,21 @@ describe('system()', function()
end)
end
+ it('works with powershell w/ UTF-8 text (#13713)', function()
+ if not helpers.has_powershell() then
+ pending("not tested; powershell was not found", function() end)
+ return
+ end
+ -- Should work with recommended config used in helper
+ helpers.set_shell_powershell()
+ eq('ああ\n', eval([[system('Write-Output "ああ"')]]))
+ -- Sanity test w/ default encoding
+ -- * on Windows, expected to default to Western European enc
+ -- * on Linux, expected to default to UTF8
+ command([[let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command ']])
+ eq(iswin() and '??\n' or 'ああ\n', eval([[system('Write-Output "ああ"')]]))
+ end)
+
it('`echo` and waits for its return', function()
feed(':call system("echo")<cr>')
screen:expect([[
@@ -554,4 +569,20 @@ describe('systemlist()', function()
assert(out[1]:sub(0, 5) == 'pid: ', out)
os_kill(out[1]:match("%d+"))
end)
+
+ it('works with powershell w/ UTF-8 text (#13713)', function()
+ if not helpers.has_powershell() then
+ pending("not tested; powershell was not found", function() end)
+ return
+ end
+ -- Should work with recommended config used in helper
+ helpers.set_shell_powershell()
+ eq({iswin() and 'あ\r' or 'あ'}, eval([[systemlist('Write-Output あ')]]))
+ -- Sanity test w/ default encoding
+ -- * on Windows, expected to default to Western European enc
+ -- * on Linux, expected to default to UTF8
+ command([[let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command ']])
+ eq({iswin() and '?\r' or 'あ'}, eval([[systemlist('Write-Output あ')]]))
+ end)
+
end)
diff --git a/test/functional/ex_cmds/make_spec.lua b/test/functional/ex_cmds/make_spec.lua
new file mode 100644
index 0000000000..3b4d22ab38
--- /dev/null
+++ b/test/functional/ex_cmds/make_spec.lua
@@ -0,0 +1,44 @@
+local helpers = require('test.functional.helpers')(after_each)
+local clear = helpers.clear
+local eval = helpers.eval
+local has_powershell = helpers.has_powershell
+local matches = helpers.matches
+local nvim = helpers.nvim
+local nvim_dir = helpers.nvim_dir
+
+describe(':make', function()
+ clear()
+ before_each(function ()
+ clear()
+ end)
+
+ describe('with powershell', function()
+ if not has_powershell() then
+ pending("not tested; powershell was not found", function() end)
+ return
+ end
+ before_each(function ()
+ helpers.set_shell_powershell()
+ end)
+
+ it('captures stderr & non zero exit code #14349', function ()
+ nvim('set_option', 'makeprg', nvim_dir..'/shell-test foo')
+ local out = eval('execute("make")')
+ -- Make program exit code correctly captured
+ matches('\nshell returned 3', out)
+ -- Error message is captured in the file and printed in the footer
+ matches('\n.*%: Unknown first argument%: foo', out)
+ end)
+
+ it('captures stderr & zero exit code #14349', function ()
+ nvim('set_option', 'makeprg', nvim_dir..'/shell-test')
+ local out = eval('execute("make")')
+ -- Ensure there are no "shell returned X" messages between
+ -- command and last line (indicating zero exit)
+ matches('LastExitCode%s+[(]', out)
+ matches('\n.*%: ready [$]', out)
+ end)
+
+ end)
+
+end)
diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua
index a03e1ae9ce..37c97f519a 100644
--- a/test/functional/ex_cmds/source_spec.lua
+++ b/test/functional/ex_cmds/source_spec.lua
@@ -9,6 +9,8 @@ local feed_command = helpers.feed_command
local write_file = helpers.write_file
local exec = helpers.exec
local eval = helpers.eval
+local exec_capture = helpers.exec_capture
+local neq = helpers.neq
describe(':source', function()
before_each(function()
@@ -90,4 +92,27 @@ describe(':source', function()
eq(12, eval('g:c'))
os.remove(test_file)
end)
+
+ it("doesn't throw E484 for lua parsing/runtime errors", function()
+ local test_file = 'test.lua'
+
+ -- Does throw E484 for unreadable files
+ local ok, result = pcall(exec_capture, ":source "..test_file ..'noexisting')
+ eq(false, ok)
+ neq(nil, result:find("E484"))
+
+ -- Doesn't throw for parsing error
+ write_file (test_file, "vim.g.c = ")
+ ok, result = pcall(exec_capture, ":source "..test_file)
+ eq(false, ok)
+ eq(nil, result:find("E484"))
+ os.remove(test_file)
+
+ -- Doesn't throw for runtime error
+ write_file (test_file, "error('Cause error anyway :D')")
+ ok, result = pcall(exec_capture, ":source "..test_file)
+ eq(false, ok)
+ eq(nil, result:find("E484"))
+ os.remove(test_file)
+ end)
end)
diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua
index bcd5e22492..b7fddc8f29 100644
--- a/test/functional/fixtures/fake-lsp-server.lua
+++ b/test/functional/fixtures/fake-lsp-server.lua
@@ -464,6 +464,23 @@ function tests.invalid_header()
io.stdout:write("Content-length: \r\n")
end
+function tests.decode_nil()
+ skeleton {
+ on_init = function(_)
+ return { capabilities = {} }
+ end;
+ body = function()
+ notify('start')
+ notify("workspace/executeCommand", {
+ arguments = { "EXTRACT_METHOD", {metadata = {field = vim.NIL}}, 3, 0, 6123, vim.NIL },
+ command = "refactor.perform",
+ title = "EXTRACT_METHOD"
+ })
+ notify('finish')
+ end;
+ }
+end
+
-- Tests will be indexed by TEST_NAME
local kill_timer = vim.loop.new_timer()
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 08ca14c3df..03ef441ef3 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -513,13 +513,15 @@ end
function module.set_shell_powershell()
local shell = iswin() and 'powershell' or 'pwsh'
assert(module.has_powershell())
- local cmd = 'Remove-Item -Force '..table.concat(iswin()
+ local set_encoding = '[Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;'
+ local cmd = set_encoding..'Remove-Item -Force '..table.concat(iswin()
and {'alias:cat', 'alias:echo', 'alias:sleep'}
or {'alias:echo'}, ',')..';'
module.source([[
let &shell = ']]..shell..[['
- set shellquote= shellpipe=\| shellxquote=
- let &shellredir = '| Out-File -Encoding UTF8'
+ set shellquote= shellxquote=
+ let &shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode'
+ let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode'
let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command ]]..cmd..[['
]])
end
@@ -878,9 +880,11 @@ function module.os_kill(pid)
or 'kill -9 '..pid..' > /dev/null'))
end
--- Create directories with non exsisting intermidiate directories
+-- Create folder with non existing parents
function module.mkdir_p(path)
- return module.meths.call_function('mkdir', {path, 'p'})
+ return os.execute((iswin()
+ and 'mkdir '..path
+ or 'mkdir -p '..path))
end
module = global_helpers.tbl_extend('error', module, global_helpers)
diff --git a/test/functional/legacy/memory_usage_spec.lua b/test/functional/legacy/memory_usage_spec.lua
index 97ac96804e..0f2d77093a 100644
--- a/test/functional/legacy/memory_usage_spec.lua
+++ b/test/functional/legacy/memory_usage_spec.lua
@@ -166,4 +166,36 @@ describe('memory usage', function()
check_result({before=before, after=after, last=last},
pcall(ok, last.last < upper))
end)
+
+ it('releases memory when closing windows when folds exist', function()
+ local pid = eval('getpid()')
+ source([[
+ new
+ " Insert lines
+ call nvim_buf_set_lines(0, 0, 0, v:false, repeat([''], 999))
+ " Create folds
+ normal! gg
+ for _ in range(500)
+ normal! zfjj
+ endfor
+ ]])
+ poke_eventloop()
+ local before = monitor_memory_usage(pid)
+ source([[
+ " Split and close window multiple times
+ for _ in range(1000)
+ split
+ close
+ endfor
+ ]])
+ poke_eventloop()
+ local after = monitor_memory_usage(pid)
+ source('bwipe!')
+ poke_eventloop()
+ -- Allow for an increase of 5% in memory usage, which accommodates minor fluctuation,
+ -- but is small enough that if memory were not released (prior to PR #14884), the test
+ -- would fail.
+ local upper = before.last * 1.05
+ check_result({before=before, after=after}, pcall(ok, after.last <= upper))
+ end)
end)
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 1b2c21783e..a5b613f0b2 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -1001,6 +1001,39 @@ describe('lua: nvim_buf_attach on_bytes', function()
}
end)
+ it("flushes delbytes on substitute", function()
+ local check_events = setup_eventcheck(verify, {"AAA", "BBB", "CCC"})
+
+ feed("gg0")
+ command("s/AAA/GGG/")
+
+ check_events {
+ { "test1", "bytes", 1, 3, 0, 0, 0, 0, 3, 3, 0, 3, 3 };
+ }
+
+ -- check that byte updates for :delete (which uses curbuf->deleted_bytes2)
+ -- are correct
+ command("delete")
+ check_events {
+ { "test1", "bytes", 1, 4, 0, 0, 0, 1, 0, 4, 0, 0, 0 };
+ }
+ end)
+
+ it("flushes delbytes on join", function()
+ local check_events = setup_eventcheck(verify, {"AAA", "BBB", "CCC"})
+
+ feed("gg0J")
+
+ check_events {
+ { "test1", "bytes", 1, 3, 0, 3, 3, 1, 0, 1, 0, 1, 1 };
+ }
+
+ command("delete")
+ check_events {
+ { "test1", "bytes", 1, 5, 0, 0, 0, 1, 0, 8, 0, 0, 0 };
+ }
+ end)
+
teardown(function()
os.remove "Xtest-reload"
os.remove "Xtest-undofile"
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index 836f514433..eff838aea3 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -1228,6 +1228,21 @@ describe('lua stdlib', function()
eq("only-local", result[8])
end)
+ it('should allow you to retrieve window opts even if they have not been set', function()
+ local result = exec_lua [[
+ local result = {}
+ table.insert(result, vim.opt.number:get())
+ table.insert(result, vim.opt_local.number:get())
+
+ vim.opt_local.number = true
+ table.insert(result, vim.opt.number:get())
+ table.insert(result, vim.opt_local.number:get())
+
+ return result
+ ]]
+ eq({false, false, true, true}, result)
+ end)
+
it('should allow all sorts of string manipulation', function()
eq({'hello', 'hello world', 'start hello world'}, exec_lua [[
local results = {}
@@ -1299,6 +1314,22 @@ describe('lua stdlib', function()
eq("*.c", wildignore[1])
end)
+ it('should work for options that are both commalist and flaglist', function()
+ local result = exec_lua [[
+ vim.opt.whichwrap = "b,s"
+ return vim.opt.whichwrap:get()
+ ]]
+
+ eq({b = true, s = true}, result)
+
+ result = exec_lua [[
+ vim.opt.whichwrap = { b = true, s = false, h = true }
+ return vim.opt.whichwrap:get()
+ ]]
+
+ eq({b = true, h = true}, result)
+ end)
+
it('should work for key-value pair options', function()
local listchars = exec_lua [[
vim.opt.listchars = "tab:>~,space:_"
@@ -1569,7 +1600,222 @@ describe('lua stdlib', function()
eq(wildignore, 'super_first,first,foo')
end)
- end)
+ it('should not remove duplicates from wildmode: #14708', function()
+ local wildmode = exec_lua [[
+ vim.opt.wildmode = {"full", "list", "full"}
+ return vim.o.wildmode
+ ]]
+
+ eq(wildmode, 'full,list,full')
+ end)
+
+ describe('option types', function()
+ it('should allow to set option with numeric value', function()
+ eq(4, exec_lua [[
+ vim.opt.tabstop = 4
+ return vim.bo.tabstop
+ ]])
+
+ matches("Invalid option type 'string' for 'tabstop'", pcall_err(exec_lua, [[
+ vim.opt.tabstop = '4'
+ ]]))
+ matches("Invalid option type 'boolean' for 'tabstop'", pcall_err(exec_lua, [[
+ vim.opt.tabstop = true
+ ]]))
+ matches("Invalid option type 'table' for 'tabstop'", pcall_err(exec_lua, [[
+ vim.opt.tabstop = {4, 2}
+ ]]))
+ matches("Invalid option type 'function' for 'tabstop'", pcall_err(exec_lua, [[
+ vim.opt.tabstop = function()
+ return 4
+ end
+ ]]))
+ end)
+
+ it('should allow to set option with boolean value', function()
+ eq(true, exec_lua [[
+ vim.opt.undofile = true
+ return vim.bo.undofile
+ ]])
+
+ matches("Invalid option type 'number' for 'undofile'", pcall_err(exec_lua, [[
+ vim.opt.undofile = 0
+ ]]))
+ matches("Invalid option type 'table' for 'undofile'", pcall_err(exec_lua, [[
+ vim.opt.undofile = {true}
+ ]]))
+ matches("Invalid option type 'string' for 'undofile'", pcall_err(exec_lua, [[
+ vim.opt.undofile = 'true'
+ ]]))
+ matches("Invalid option type 'function' for 'undofile'", pcall_err(exec_lua, [[
+ vim.opt.undofile = function()
+ return true
+ end
+ ]]))
+ end)
+
+ it('should allow to set option with array or string value', function()
+ eq('indent,eol,start', exec_lua [[
+ vim.opt.backspace = {'indent','eol','start'}
+ return vim.go.backspace
+ ]])
+ eq('indent,eol,start', exec_lua [[
+ vim.opt.backspace = 'indent,eol,start'
+ return vim.go.backspace
+ ]])
+
+ matches("Invalid option type 'boolean' for 'backspace'", pcall_err(exec_lua, [[
+ vim.opt.backspace = true
+ ]]))
+ matches("Invalid option type 'number' for 'backspace'", pcall_err(exec_lua, [[
+ vim.opt.backspace = 2
+ ]]))
+ matches("Invalid option type 'function' for 'backspace'", pcall_err(exec_lua, [[
+ vim.opt.backspace = function()
+ return 'indent,eol,start'
+ end
+ ]]))
+ end)
+
+ it('should allow set option with map or string value', function()
+ eq("eol:~,space:.", exec_lua [[
+ vim.opt.listchars = {
+ eol = "~",
+ space = ".",
+ }
+ return vim.o.listchars
+ ]])
+ eq("eol:~,space:.,tab:>~", exec_lua [[
+ vim.opt.listchars = "eol:~,space:.,tab:>~"
+ return vim.o.listchars
+ ]])
+
+ matches("Invalid option type 'boolean' for 'listchars'", pcall_err(exec_lua, [[
+ vim.opt.listchars = true
+ ]]))
+ matches("Invalid option type 'number' for 'listchars'", pcall_err(exec_lua, [[
+ vim.opt.listchars = 2
+ ]]))
+ matches("Invalid option type 'function' for 'listchars'", pcall_err(exec_lua, [[
+ vim.opt.listchars = function()
+ return "eol:~,space:.,tab:>~"
+ end
+ ]]))
+ end)
+
+ it('should allow set option with set or string value', function()
+ local ww = exec_lua [[
+ vim.opt.whichwrap = {
+ b = true,
+ s = 1,
+ }
+ return vim.go.whichwrap
+ ]]
+
+ eq(ww, "b,s")
+ eq("b,s,<,>,[,]", exec_lua [[
+ vim.opt.whichwrap = "b,s,<,>,[,]"
+ return vim.go.whichwrap
+ ]])
+
+ matches("Invalid option type 'boolean' for 'whichwrap'", pcall_err(exec_lua, [[
+ vim.opt.whichwrap = true
+ ]]))
+ matches("Invalid option type 'number' for 'whichwrap'", pcall_err(exec_lua, [[
+ vim.opt.whichwrap = 2
+ ]]))
+ matches("Invalid option type 'function' for 'whichwrap'", pcall_err(exec_lua, [[
+ vim.opt.whichwrap = function()
+ return "b,s,<,>,[,]"
+ end
+ ]]))
+ end)
+ end)
+
+ -- isfname=a,b,c,,,d,e,f
+ it('can handle isfname ,,,', function()
+ local result = exec_lua [[
+ vim.opt.isfname = "a,b,,,c"
+ return { vim.opt.isfname:get(), vim.api.nvim_get_option('isfname') }
+ ]]
+
+ eq({{",", "a", "b", "c"}, "a,b,,,c"}, result)
+ end)
+
+ -- isfname=a,b,c,^,,def
+ it('can handle isfname ,^,,', function()
+ local result = exec_lua [[
+ vim.opt.isfname = "a,b,^,,c"
+ return { vim.opt.isfname:get(), vim.api.nvim_get_option('isfname') }
+ ]]
+
+ eq({{"^,", "a", "b", "c"}, "a,b,^,,c"}, result)
+ end)
+
+
+
+ describe('https://github.com/neovim/neovim/issues/14828', function()
+ it('gives empty list when item is empty:array', function()
+ eq({}, exec_lua [[
+ vim.cmd("set wildignore=")
+ return vim.opt.wildignore:get()
+ ]])
+
+ eq({}, exec_lua [[
+ vim.opt.wildignore = {}
+ return vim.opt.wildignore:get()
+ ]])
+ end)
+
+ it('gives empty list when item is empty:set', function()
+ eq({}, exec_lua [[
+ vim.cmd("set formatoptions=")
+ return vim.opt.formatoptions:get()
+ ]])
+
+ eq({}, exec_lua [[
+ vim.opt.formatoptions = {}
+ return vim.opt.formatoptions:get()
+ ]])
+ end)
+
+ it('does not append to empty item', function()
+ eq({"*.foo", "*.bar"}, exec_lua [[
+ vim.opt.wildignore = {}
+ vim.opt.wildignore:append { "*.foo", "*.bar" }
+
+ return vim.opt.wildignore:get()
+ ]])
+ end)
+
+ it('does not prepend to empty item', function()
+ eq({"*.foo", "*.bar"}, exec_lua [[
+ vim.opt.wildignore = {}
+ vim.opt.wildignore:prepend { "*.foo", "*.bar" }
+
+ return vim.opt.wildignore:get()
+ ]])
+ end)
+
+ it('append to empty set', function()
+ eq({ t = true }, exec_lua [[
+ vim.opt.formatoptions = {}
+ vim.opt.formatoptions:append("t")
+
+ return vim.opt.formatoptions:get()
+ ]])
+ end)
+
+ it('prepend to empty set', function()
+ eq({ t = true }, exec_lua [[
+ vim.opt.formatoptions = {}
+ vim.opt.formatoptions:prepend("t")
+
+ return vim.opt.formatoptions:get()
+ ]])
+ end)
+ end)
+ end) -- vim.opt
it('vim.cmd', function()
exec_lua [[
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 663271deab..35cc2d3075 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -105,8 +105,8 @@ local function test_rpc_server(config)
return NIL
end
if method == 'handler' then
- if config.on_callback then
- config.on_callback(unpack(args))
+ if config.on_handler then
+ config.on_handler(unpack(args))
end
end
return NIL
@@ -215,7 +215,7 @@ describe('LSP', function()
end)
it('should run correctly', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "test", {}, 1};
}
test_rpc_server {
@@ -232,15 +232,15 @@ describe('LSP', function()
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
-- Note that NIL must be used here.
- -- on_callback(err, method, result, client_id)
- on_callback = function(...)
- eq(table.remove(expected_callbacks), {...})
+ -- on_handler(err, method, result, client_id)
+ on_handler = function(...)
+ eq(table.remove(expected_handlers), {...})
end;
}
end)
it('should fail', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "test", {}, 1};
}
test_rpc_server {
@@ -255,8 +255,8 @@ describe('LSP', function()
assert_log(pesc([[assert_eq failed: left == "\"shutdown\"", right == "\"test\""]]),
fake_lsp_logfile)
end;
- on_callback = function(...)
- eq(table.remove(expected_callbacks), {...}, "expected callback")
+ on_handler = function(...)
+ eq(table.remove(expected_handlers), {...}, "expected handler")
end;
}
end)
@@ -266,7 +266,7 @@ describe('LSP', function()
pending('hangs the build on openbsd #14028, re-enable with freeze timeout #14204')
return
end
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1, NIL};
{NIL, "test", {}, 1};
}
@@ -282,14 +282,14 @@ describe('LSP', function()
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(...)
- eq(table.remove(expected_callbacks), {...}, "expected callback")
+ on_handler = function(...)
+ eq(table.remove(expected_handlers), {...}, "expected handler")
end;
}
end)
it('client should return settings via workspace/configuration handler', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1};
{NIL, "workspace/configuration", { items = {
{ section = "testSetting1" };
@@ -307,8 +307,8 @@ describe('LSP', function()
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(err, method, params, client_id)
- eq(table.remove(expected_callbacks), {err, method, params, client_id}, "expected callback")
+ on_handler = function(err, method, params, client_id)
+ eq(table.remove(expected_handlers), {err, method, params, client_id}, "expected handler")
if method == 'start' then
exec_lua([=[
local client = vim.lsp.get_client_by_id(TEST_RPC_CLIENT_ID)
@@ -344,7 +344,7 @@ describe('LSP', function()
end)
it('should verify capabilities sent', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1};
}
test_rpc_server {
@@ -361,14 +361,14 @@ describe('LSP', function()
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(...)
- eq(table.remove(expected_callbacks), {...}, "expected callback")
+ on_handler = function(...)
+ eq(table.remove(expected_handlers), {...}, "expected handler")
end;
}
end)
it('client.supports_methods() should validate capabilities', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1};
}
test_rpc_server {
@@ -395,14 +395,14 @@ describe('LSP', function()
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(...)
- eq(table.remove(expected_callbacks), {...}, "expected callback")
+ on_handler = function(...)
+ eq(table.remove(expected_handlers), {...}, "expected handler")
end;
}
end)
it('should call unsupported_method when trying to call an unsupported method', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1};
}
test_rpc_server {
@@ -412,7 +412,7 @@ describe('LSP', function()
BUFFER = vim.api.nvim_get_current_buf()
lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID)
vim.lsp.handlers['textDocument/typeDefinition'] = function(err, method)
- vim.lsp._last_lsp_callback = { err = err; method = method }
+ vim.lsp._last_lsp_handler = { err = err; method = method }
end
vim.lsp._unsupported_method = function(method)
vim.lsp._last_unsupported_method = method
@@ -425,7 +425,7 @@ describe('LSP', function()
client.stop()
local method = exec_lua("return vim.lsp._last_unsupported_method")
eq("textDocument/typeDefinition", method)
- local lsp_cb_call = exec_lua("return vim.lsp._last_lsp_callback")
+ local lsp_cb_call = exec_lua("return vim.lsp._last_lsp_handler")
eq("fake-error", lsp_cb_call.err)
eq("textDocument/typeDefinition", lsp_cb_call.method)
exec_lua [[
@@ -436,14 +436,14 @@ describe('LSP', function()
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(...)
- eq(table.remove(expected_callbacks), {...}, "expected callback")
+ on_handler = function(...)
+ eq(table.remove(expected_handlers), {...}, "expected handler")
end;
}
end)
it('shouldn\'t call unsupported_method when no client and trying to call an unsupported method', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1};
}
test_rpc_server {
@@ -451,7 +451,7 @@ describe('LSP', function()
on_setup = function()
exec_lua([=[
vim.lsp.handlers['textDocument/typeDefinition'] = function(err, method)
- vim.lsp._last_lsp_callback = { err = err; method = method }
+ vim.lsp._last_lsp_handler = { err = err; method = method }
end
vim.lsp._unsupported_method = function(method)
vim.lsp._last_unsupported_method = method
@@ -463,20 +463,20 @@ describe('LSP', function()
on_init = function(client)
client.stop()
eq(NIL, exec_lua("return vim.lsp._last_unsupported_method"))
- eq(NIL, exec_lua("return vim.lsp._last_lsp_callback"))
+ eq(NIL, exec_lua("return vim.lsp._last_lsp_handler"))
end;
on_exit = function(code, signal)
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(...)
- eq(table.remove(expected_callbacks), {...}, "expected callback")
+ on_handler = function(...)
+ eq(table.remove(expected_handlers), {...}, "expected handler")
end;
}
end)
it('should not send didOpen if the buffer closes before init', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1};
{NIL, "finish", {}, 1};
}
@@ -509,8 +509,8 @@ describe('LSP', function()
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(err, method, params, client_id)
- eq(table.remove(expected_callbacks), {err, method, params, client_id}, "expected callback")
+ on_handler = function(err, method, params, client_id)
+ eq(table.remove(expected_handlers), {err, method, params, client_id}, "expected handler")
if method == 'finish' then
client.stop()
end
@@ -519,7 +519,7 @@ describe('LSP', function()
end)
it('should check the body sent attaching before init', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1};
{NIL, "finish", {}, 1};
{NIL, "start", {}, 1};
@@ -552,11 +552,11 @@ describe('LSP', function()
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(err, method, params, client_id)
+ on_handler = function(err, method, params, client_id)
if method == 'start' then
client.notify('finish')
end
- eq(table.remove(expected_callbacks), {err, method, params, client_id}, "expected callback")
+ eq(table.remove(expected_handlers), {err, method, params, client_id}, "expected handler")
if method == 'finish' then
client.stop()
end
@@ -565,7 +565,7 @@ describe('LSP', function()
end)
it('should check the body sent attaching after init', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1};
{NIL, "finish", {}, 1};
{NIL, "start", {}, 1};
@@ -595,11 +595,11 @@ describe('LSP', function()
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(err, method, params, client_id)
+ on_handler = function(err, method, params, client_id)
if method == 'start' then
client.notify('finish')
end
- eq(table.remove(expected_callbacks), {err, method, params, client_id}, "expected callback")
+ eq(table.remove(expected_handlers), {err, method, params, client_id}, "expected handler")
if method == 'finish' then
client.stop()
end
@@ -608,7 +608,7 @@ describe('LSP', function()
end)
it('should check the body and didChange full', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1};
{NIL, "finish", {}, 1};
{NIL, "start", {}, 1};
@@ -638,7 +638,7 @@ describe('LSP', function()
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(err, method, params, client_id)
+ on_handler = function(err, method, params, client_id)
if method == 'start' then
exec_lua [[
vim.api.nvim_buf_set_lines(BUFFER, 1, 2, false, {
@@ -647,7 +647,7 @@ describe('LSP', function()
]]
client.notify('finish')
end
- eq(table.remove(expected_callbacks), {err, method, params, client_id}, "expected callback")
+ eq(table.remove(expected_handlers), {err, method, params, client_id}, "expected handler")
if method == 'finish' then
client.stop()
end
@@ -656,7 +656,7 @@ describe('LSP', function()
end)
it('should check the body and didChange full with noeol', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1};
{NIL, "finish", {}, 1};
{NIL, "start", {}, 1};
@@ -687,7 +687,7 @@ describe('LSP', function()
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(err, method, params, client_id)
+ on_handler = function(err, method, params, client_id)
if method == 'start' then
exec_lua [[
vim.api.nvim_buf_set_lines(BUFFER, 1, 2, false, {
@@ -696,7 +696,7 @@ describe('LSP', function()
]]
client.notify('finish')
end
- eq(table.remove(expected_callbacks), {err, method, params, client_id}, "expected callback")
+ eq(table.remove(expected_handlers), {err, method, params, client_id}, "expected handler")
if method == 'finish' then
client.stop()
end
@@ -705,7 +705,7 @@ describe('LSP', function()
end)
it('should check the body and didChange incremental', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1};
{NIL, "finish", {}, 1};
{NIL, "start", {}, 1};
@@ -736,7 +736,7 @@ describe('LSP', function()
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(err, method, params, client_id)
+ on_handler = function(err, method, params, client_id)
if method == 'start' then
exec_lua [[
vim.api.nvim_buf_set_lines(BUFFER, 1, 2, false, {
@@ -745,7 +745,7 @@ describe('LSP', function()
]]
client.notify('finish')
end
- eq(table.remove(expected_callbacks), {err, method, params, client_id}, "expected callback")
+ eq(table.remove(expected_handlers), {err, method, params, client_id}, "expected handler")
if method == 'finish' then
client.stop()
end
@@ -755,7 +755,7 @@ describe('LSP', function()
-- TODO(askhan) we don't support full for now, so we can disable these tests.
pending('should check the body and didChange incremental normal mode editing', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1};
{NIL, "finish", {}, 1};
{NIL, "start", {}, 1};
@@ -785,12 +785,12 @@ describe('LSP', function()
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(err, method, params, client_id)
+ on_handler = function(err, method, params, client_id)
if method == 'start' then
helpers.command("normal! 1Go")
client.notify('finish')
end
- eq(table.remove(expected_callbacks), {err, method, params, client_id}, "expected callback")
+ eq(table.remove(expected_handlers), {err, method, params, client_id}, "expected handler")
if method == 'finish' then
client.stop()
end
@@ -799,7 +799,7 @@ describe('LSP', function()
end)
it('should check the body and didChange full with 2 changes', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1};
{NIL, "finish", {}, 1};
{NIL, "start", {}, 1};
@@ -829,7 +829,7 @@ describe('LSP', function()
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(err, method, params, client_id)
+ on_handler = function(err, method, params, client_id)
if method == 'start' then
exec_lua [[
vim.api.nvim_buf_set_lines(BUFFER, 1, 2, false, {
@@ -841,7 +841,7 @@ describe('LSP', function()
]]
client.notify('finish')
end
- eq(table.remove(expected_callbacks), {err, method, params, client_id}, "expected callback")
+ eq(table.remove(expected_handlers), {err, method, params, client_id}, "expected handler")
if method == 'finish' then
client.stop()
end
@@ -850,7 +850,7 @@ describe('LSP', function()
end)
it('should check the body and didChange full lifecycle', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1};
{NIL, "finish", {}, 1};
{NIL, "start", {}, 1};
@@ -880,7 +880,7 @@ describe('LSP', function()
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(err, method, params, client_id)
+ on_handler = function(err, method, params, client_id)
if method == 'start' then
exec_lua [[
vim.api.nvim_buf_set_lines(BUFFER, 1, 2, false, {
@@ -893,7 +893,7 @@ describe('LSP', function()
]]
client.notify('finish')
end
- eq(table.remove(expected_callbacks), {err, method, params, client_id}, "expected callback")
+ eq(table.remove(expected_handlers), {err, method, params, client_id}, "expected handler")
if method == 'finish' then
client.stop()
end
@@ -904,7 +904,7 @@ describe('LSP', function()
describe("parsing tests", function()
it('should handle invalid content-length correctly', function()
- local expected_callbacks = {
+ local expected_handlers = {
{NIL, "shutdown", {}, 1};
{NIL, "finish", {}, 1};
{NIL, "start", {}, 1};
@@ -923,7 +923,49 @@ describe('LSP', function()
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
on_handler = function(err, method, params, client_id)
- eq(table.remove(expected_callbacks), {err, method, params, client_id}, "expected handler")
+ eq(table.remove(expected_handlers), {err, method, params, client_id}, "expected handler")
+ end;
+ }
+ end)
+
+ it('should not trim vim.NIL from the end of a list', function()
+ local expected_handlers = {
+ {NIL, "shutdown", {}, 1};
+ {NIL, "finish", {}, 1};
+ {NIL, "workspace/executeCommand", {
+ arguments = { "EXTRACT_METHOD", {metadata = {}}, 3, 0, 6123, NIL },
+ command = "refactor.perform",
+ title = "EXTRACT_METHOD"
+ }, 1};
+ {NIL, "start", {}, 1};
+ }
+ local client
+ test_rpc_server {
+ test_name = "decode_nil";
+ on_setup = function()
+ exec_lua [[
+ BUFFER = vim.api.nvim_create_buf(false, true)
+ vim.api.nvim_buf_set_lines(BUFFER, 0, -1, false, {
+ "testing";
+ "123";
+ })
+ ]]
+ end;
+ on_init = function(_client)
+ client = _client
+ exec_lua [[
+ assert(lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID))
+ ]]
+ end;
+ on_exit = function(code, signal)
+ eq(0, code, "exit code", fake_lsp_logfile)
+ eq(0, signal, "exit signal", fake_lsp_logfile)
+ end;
+ on_handler = function(err, method, params, client_id)
+ eq(table.remove(expected_handlers), {err, method, params, client_id}, "expected handler")
+ if method == 'finish' then
+ client.stop()
+ end
end;
}
end)
diff --git a/test/functional/provider/clipboard_spec.lua b/test/functional/provider/clipboard_spec.lua
index 2c681eb9d8..e5e21f11a6 100644
--- a/test/functional/provider/clipboard_spec.lua
+++ b/test/functional/provider/clipboard_spec.lua
@@ -506,6 +506,20 @@ describe('clipboard (with fake clipboard.vim)', function()
feed('p')
eq('textstar', meths.get_current_line())
end)
+
+ it('Block paste works currectly', function()
+ insert([[
+ aabbcc
+ ddeeff
+ ]])
+ feed('gg^<C-v>') -- Goto start of top line enter visual block mode
+ feed('3ljy^k') -- yank 4x2 block & goto initial location
+ feed('P') -- Paste it infront
+ expect([[
+ aabbaabbcc
+ ddeeddeeff
+ ]])
+ end)
end)
describe('clipboard=unnamedplus', function()
diff --git a/test/functional/ui/tabline_spec.lua b/test/functional/ui/tabline_spec.lua
index 23aae81745..ab8d63cda1 100644
--- a/test/functional/ui/tabline_spec.lua
+++ b/test/functional/ui/tabline_spec.lua
@@ -4,14 +4,17 @@ local clear, command, eq = helpers.clear, helpers.command, helpers.eq
describe('ui/ext_tabline', function()
local screen
- local event_tabs, event_curtab
+ local event_tabs, event_curtab, event_curbuf, event_buffers
before_each(function()
clear()
screen = Screen.new(25, 5)
screen:attach({rgb=true, ext_tabline=true})
- function screen:_handle_tabline_update(curtab, tabs)
- event_curtab, event_tabs = curtab, tabs
+ function screen:_handle_tabline_update(curtab, tabs, curbuf, buffers)
+ event_curtab = curtab
+ event_tabs = tabs
+ event_curbuf = curbuf
+ event_buffers = buffers
end
end)
@@ -45,4 +48,38 @@ describe('ui/ext_tabline', function()
eq(expected_tabs, event_tabs)
end}
end)
+
+ it('buffer UI events', function()
+ local expected_buffers_initial= {
+ {buffer = { id = 1 }, name = '[No Name]'},
+ }
+
+ screen:expect{grid=[[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], condition=function()
+ eq({ id = 1}, event_curbuf)
+ eq(expected_buffers_initial, event_buffers)
+ end}
+
+ command("badd another-buffer")
+ command("bnext")
+
+ local expected_buffers = {
+ {buffer = { id = 2 }, name = 'another-buffer'},
+ }
+ screen:expect{grid=[[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], condition=function()
+ eq({ id = 2 }, event_curbuf)
+ eq(expected_buffers, event_buffers)
+ end}
+ end)
end)
diff --git a/test/unit/eval/typval_spec.lua b/test/unit/eval/typval_spec.lua
index 7c03005529..d81e272877 100644
--- a/test/unit/eval/typval_spec.lua
+++ b/test/unit/eval/typval_spec.lua
@@ -2623,7 +2623,7 @@ describe('typval.c', function()
describe('check_lock()', function()
local function tv_check_lock(lock, name, name_len, emsg)
return check_emsg(function()
- return lib.tv_check_lock(lock, name, name_len)
+ return lib.var_check_lock(lock, name, name_len)
end, emsg)
end
itp('works', function()
diff --git a/test/unit/marktree_spec.lua b/test/unit/marktree_spec.lua
index 56acc0f93e..cd9c7bef13 100644
--- a/test/unit/marktree_spec.lua
+++ b/test/unit/marktree_spec.lua
@@ -186,5 +186,20 @@ describe('marktree', function()
lib.marktree_check(tree)
shadoworder(tree, shadow, iter2)
end
+
+ -- Check iterator validity for 2 specific edge cases:
+ -- https://github.com/neovim/neovim/pull/14719
+ lib.marktree_clear(tree)
+ for i = 1,20 do
+ lib.marktree_put(tree, i, i, false)
+ end
+
+ lib.marktree_itr_get(tree, 10, 10, iter)
+ lib.marktree_del_itr(tree, iter, false)
+ eq(11, iter[0].node.key[iter[0].i].pos.col)
+
+ lib.marktree_itr_get(tree, 11, 11, iter)
+ lib.marktree_del_itr(tree, iter, false)
+ eq(12, iter[0].node.key[iter[0].i].pos.col)
end)
end)