aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/benchmark/autocmd_spec.lua4
-rw-r--r--test/benchmark/iter_spec.lua4
-rw-r--r--test/benchmark/treesitter_spec.lua4
-rw-r--r--test/busted_runner.lua2
-rw-r--r--test/functional/core/startup_spec.lua2
-rw-r--r--test/functional/ex_cmds/source_spec.lua108
-rw-r--r--test/functional/fixtures/fake-lsp-server.lua2
-rw-r--r--test/functional/fixtures/start/nvim-leftpad/lua/async_leftpad.lua2
-rw-r--r--test/functional/legacy/put_spec.lua25
-rw-r--r--test/functional/lua/highlight_spec.lua2
-rw-r--r--test/functional/lua/loop_spec.lua18
-rw-r--r--test/functional/lua/overrides_spec.lua4
-rw-r--r--test/functional/lua/thread_spec.lua42
-rw-r--r--test/functional/lua/vim_spec.lua16
-rw-r--r--test/functional/plugin/lsp/helpers.lua2
-rw-r--r--test/functional/plugin/lsp_spec.lua64
-rw-r--r--test/functional/terminal/tui_spec.lua6
-rw-r--r--test/functional/treesitter/parser_spec.lua4
-rw-r--r--test/functional/ui/decorations_spec.lua41
-rw-r--r--test/functional/ui/spell_spec.lua24
-rw-r--r--test/old/testdir/test_functions.vim28
-rw-r--r--test/old/testdir/test_put.vim18
-rw-r--r--test/old/testdir/test_registers.vim5
-rw-r--r--test/old/testdir/test_spell.vim11
-rw-r--r--test/old/testdir/test_utf8.vim15
-rw-r--r--test/old/testdir/test_window_cmd.vim13
26 files changed, 338 insertions, 128 deletions
diff --git a/test/benchmark/autocmd_spec.lua b/test/benchmark/autocmd_spec.lua
index f243d9c94d..cd1af23640 100644
--- a/test/benchmark/autocmd_spec.lua
+++ b/test/benchmark/autocmd_spec.lua
@@ -12,10 +12,10 @@ describe('autocmd perf', function()
exec_lua([[
out = {}
function start()
- ts = vim.loop.hrtime()
+ ts = vim.uv.hrtime()
end
function stop(name)
- out[#out+1] = ('%14.6f ms - %s'):format((vim.loop.hrtime() - ts) / 1000000, name)
+ out[#out+1] = ('%14.6f ms - %s'):format((vim.uv.hrtime() - ts) / 1000000, name)
end
]])
end)
diff --git a/test/benchmark/iter_spec.lua b/test/benchmark/iter_spec.lua
index 8d77054e83..d176079997 100644
--- a/test/benchmark/iter_spec.lua
+++ b/test/benchmark/iter_spec.lua
@@ -35,9 +35,9 @@ describe('vim.iter perf', function()
local stats = {}
local result
for _ = 1, N do
- local tic = vim.loop.hrtime()
+ local tic = vim.uv.hrtime()
result = f(input)
- local toc = vim.loop.hrtime()
+ local toc = vim.uv.hrtime()
stats[#stats + 1] = (toc - tic) / 1000000
end
table.sort(stats)
diff --git a/test/benchmark/treesitter_spec.lua b/test/benchmark/treesitter_spec.lua
index 5ce128c54a..6d82f5de8d 100644
--- a/test/benchmark/treesitter_spec.lua
+++ b/test/benchmark/treesitter_spec.lua
@@ -37,7 +37,7 @@ describe('treesitter perf', function()
return "qq" .. acc .. "q"
end
- local start = vim.loop.hrtime()
+ local start = vim.uv.hrtime()
keys(mk_keys(10))
for _ = 1, 100 do
@@ -45,7 +45,7 @@ describe('treesitter perf', function()
vim.cmd'redraw!'
end
- return vim.loop.hrtime() - start
+ return vim.uv.hrtime() - start
]]
end)
diff --git a/test/busted_runner.lua b/test/busted_runner.lua
index 5604790069..d6864c6492 100644
--- a/test/busted_runner.lua
+++ b/test/busted_runner.lua
@@ -1,4 +1,4 @@
-local platform = vim.loop.os_uname()
+local platform = vim.uv.os_uname()
local deps_install_dir = os.getenv 'DEPS_INSTALL_DIR'
local suffix = (platform and platform.sysname:lower():find'windows') and '.dll' or '.so'
package.path = deps_install_dir.."/share/lua/5.1/?.lua;"..deps_install_dir.."/share/lua/5.1/?/init.lua;"..package.path
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index fe1b8e1c4e..54886d0c43 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -110,7 +110,7 @@ describe('startup', function()
exec_lua [[
local asan_options = os.getenv 'ASAN_OPTIONS'
if asan_options ~= nil and asan_options ~= '' then
- vim.loop.os_setenv('ASAN_OPTIONS', asan_options..':detect_leaks=0')
+ vim.uv.os_setenv('ASAN_OPTIONS', asan_options..':detect_leaks=0')
end
]]
-- nvim -l foo.lua -arg1 -- a b c
diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua
index 02f5bff021..24987354a4 100644
--- a/test/functional/ex_cmds/source_spec.lua
+++ b/test/functional/ex_cmds/source_spec.lua
@@ -7,6 +7,7 @@ local meths = helpers.meths
local feed = helpers.feed
local feed_command = helpers.feed_command
local write_file = helpers.write_file
+local tmpname = helpers.tmpname
local exec = helpers.exec
local exc_exec = helpers.exc_exec
local exec_lua = helpers.exec_lua
@@ -179,56 +180,65 @@ describe(':source', function()
os.remove(test_file)
end)
- it('can source selected region in lua file', function()
- local test_file = 'test.lua'
-
- write_file (test_file, [[
- vim.g.b = 5
- vim.g.b = 6
- vim.g.b = 7
- a = [=[
- "\ a
- \ b]=]
- ]])
-
- command('edit '..test_file)
-
- feed('ggjV')
- feed_command(':source')
- eq(6, eval('g:b'))
-
- feed('GVkk')
- feed_command(':source')
- eq(' "\\ a\n \\ b', exec_lua('return _G.a'))
-
- os.remove(test_file)
- end)
-
- it('can source current lua buffer without argument', function()
- local test_file = 'test.lua'
-
- write_file(test_file, [[
- vim.g.c = 10
- vim.g.c = 11
- vim.g.c = 12
- a = [=[
- \ 1
- "\ 2]=]
- vim.g.sfile_value = vim.fn.expand('<sfile>')
- vim.g.stack_value = vim.fn.expand('<stack>')
- vim.g.script_value = vim.fn.expand('<script>')
- ]])
-
- command('edit '..test_file)
- feed_command(':source')
-
- eq(12, eval('g:c'))
- eq(' \\ 1\n "\\ 2', exec_lua('return _G.a'))
- eq(':source (no file)', meths.get_var('sfile_value'))
- eq(':source (no file)', meths.get_var('stack_value'))
- eq(':source (no file)', meths.get_var('script_value'))
+ describe('can source current buffer', function()
+ local function test_source_lua_curbuf()
+ it('selected region', function()
+ insert([[
+ vim.g.b = 5
+ vim.g.b = 6
+ vim.g.b = 7
+ a = [=[
+ "\ a
+ \ b]=]
+ ]])
+ feed('dd')
+
+ feed('ggjV')
+ feed_command(':source')
+ eq(6, eval('g:b'))
+
+ feed('GVkk')
+ feed_command(':source')
+ eq(' "\\ a\n \\ b', exec_lua('return _G.a'))
+ end)
+
+ it('whole buffer', function()
+ insert([[
+ vim.g.c = 10
+ vim.g.c = 11
+ vim.g.c = 12
+ a = [=[
+ \ 1
+ "\ 2]=]
+ vim.g.sfile_value = vim.fn.expand('<sfile>')
+ vim.g.stack_value = vim.fn.expand('<stack>')
+ vim.g.script_value = vim.fn.expand('<script>')
+ ]])
+ feed('dd')
+
+ feed_command(':source')
+
+ eq(12, eval('g:c'))
+ eq(' \\ 1\n "\\ 2', exec_lua('return _G.a'))
+ eq(':source (no file)', meths.get_var('sfile_value'))
+ eq(':source (no file)', meths.get_var('stack_value'))
+ eq(':source (no file)', meths.get_var('script_value'))
+ end)
+ end
- os.remove(test_file)
+ describe('with ft=lua', function()
+ before_each(function()
+ command('setlocal ft=lua')
+ end)
+ test_source_lua_curbuf()
+ end)
+
+ describe('with .lua extension', function()
+ before_each(function()
+ command('edit ' .. tmpname() .. '.lua')
+ end)
+ test_source_lua_curbuf()
+ end)
end)
it("doesn't throw E484 for lua parsing/runtime errors", function()
diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua
index 001cd5770a..dc0428afdc 100644
--- a/test/functional/fixtures/fake-lsp-server.lua
+++ b/test/functional/fixtures/fake-lsp-server.lua
@@ -950,7 +950,7 @@ local test_name = arg[1]
local timeout = arg[2]
assert(type(test_name) == 'string', 'test_name must be specified as first arg.')
-local kill_timer = vim.loop.new_timer()
+local kill_timer = vim.uv.new_timer()
kill_timer:start(timeout or 1e3, 0, function()
kill_timer:stop()
kill_timer:close()
diff --git a/test/functional/fixtures/start/nvim-leftpad/lua/async_leftpad.lua b/test/functional/fixtures/start/nvim-leftpad/lua/async_leftpad.lua
index 45226ce24b..ffbd8a4f83 100644
--- a/test/functional/fixtures/start/nvim-leftpad/lua/async_leftpad.lua
+++ b/test/functional/fixtures/start/nvim-leftpad/lua/async_leftpad.lua
@@ -1,5 +1,5 @@
return function (val, res)
local handle
- handle = vim.loop.new_async(function() _G[res] = require'leftpad'(val) handle:close() end)
+ handle = vim.uv.new_async(function() _G[res] = require'leftpad'(val) handle:close() end)
handle:send()
end
diff --git a/test/functional/legacy/put_spec.lua b/test/functional/legacy/put_spec.lua
index e83fde774a..4a42a1c8a3 100644
--- a/test/functional/legacy/put_spec.lua
+++ b/test/functional/legacy/put_spec.lua
@@ -70,4 +70,29 @@ describe('put', function()
|
]])
end)
+
+ -- oldtest: Test_put_in_last_displayed_line()
+ it('in last displayed line', function()
+ local screen = Screen.new(75, 10)
+ screen:attach()
+ source([[
+ autocmd CursorMoved * eval line('w$')
+ let @a = 'x'->repeat(&columns * 2 - 2)
+ eval range(&lines)->setline(1)
+ call feedkeys('G"ap')
+ ]])
+
+ screen:expect([[
+ 2 |
+ 3 |
+ 4 |
+ 5 |
+ 6 |
+ 7 |
+ 8 |
+ 9xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^x |
+ |
+ ]])
+ end)
end)
diff --git a/test/functional/lua/highlight_spec.lua b/test/functional/lua/highlight_spec.lua
index 60d0ed5017..8e499f1e79 100644
--- a/test/functional/lua/highlight_spec.lua
+++ b/test/functional/lua/highlight_spec.lua
@@ -24,7 +24,7 @@ describe('vim.highlight.on_yank', function()
it('does not close timer twice', function()
exec_lua([[
vim.highlight.on_yank({timeout = 10, on_macro = true, event = {operator = "y"}})
- vim.loop.sleep(10)
+ vim.uv.sleep(10)
vim.schedule(function()
vim.highlight.on_yank({timeout = 0, on_macro = true, event = {operator = "y"}})
end)
diff --git a/test/functional/lua/loop_spec.lua b/test/functional/lua/loop_spec.lua
index 7f3787d7bf..c0924fa0c0 100644
--- a/test/functional/lua/loop_spec.lua
+++ b/test/functional/lua/loop_spec.lua
@@ -14,24 +14,24 @@ local retry = helpers.retry
before_each(clear)
-describe('vim.loop', function()
+describe('vim.uv', function()
it('version', function()
- assert(funcs.luaeval('vim.loop.version()')>=72961, "libuv version too old")
- matches("(%d+)%.(%d+)%.(%d+)", funcs.luaeval('vim.loop.version_string()'))
+ assert(funcs.luaeval('vim.uv.version()')>=72961, "libuv version too old")
+ matches("(%d+)%.(%d+)%.(%d+)", funcs.luaeval('vim.uv.version_string()'))
end)
it('timer', function()
exec_lua('vim.api.nvim_set_var("coroutine_cnt", 0)', {})
local code=[[
- local loop = vim.loop
+ local uv = vim.uv
local touch = 0
local function wait(ms)
local this = coroutine.running()
assert(this)
- local timer = loop.new_timer()
+ local timer = uv.new_timer()
timer:start(ms, 0, vim.schedule_wrap(function ()
timer:close()
touch = touch + 1
@@ -73,7 +73,7 @@ describe('vim.loop', function()
-- deferred API functions are disabled, as their safety can't be guaranteed
exec_lua([[
- local timer = vim.loop.new_timer()
+ local timer = vim.uv.new_timer()
timer:start(20, 0, function ()
_G.is_fast = vim.in_fast_event()
timer:close()
@@ -101,7 +101,7 @@ describe('vim.loop', function()
-- callbacks can be scheduled to be executed in the main event loop
-- where the entire API is available
exec_lua([[
- local timer = vim.loop.new_timer()
+ local timer = vim.uv.new_timer()
timer:start(20, 0, vim.schedule_wrap(function ()
_G.is_fast = vim.in_fast_event()
timer:close()
@@ -127,7 +127,7 @@ describe('vim.loop', function()
-- fast (not deferred) API functions are allowed to be called directly
exec_lua([[
- local timer = vim.loop.new_timer()
+ local timer = vim.uv.new_timer()
timer:start(20, 0, function ()
timer:close()
-- input is queued for processing after the callback returns
@@ -151,6 +151,6 @@ describe('vim.loop', function()
end)
it("is equal to require('luv')", function()
- eq(true, exec_lua("return vim.loop == require('luv')"))
+ eq(true, exec_lua("return vim.uv == require('luv')"))
end)
end)
diff --git a/test/functional/lua/overrides_spec.lua b/test/functional/lua/overrides_spec.lua
index 68e2525151..0fd8cb2f6a 100644
--- a/test/functional/lua/overrides_spec.lua
+++ b/test/functional/lua/overrides_spec.lua
@@ -119,7 +119,7 @@ describe('print', function()
exec_lua([[
local cmd = ...
function test()
- local timer = vim.loop.new_timer()
+ local timer = vim.uv.new_timer()
local done = false
timer:start(10, 0, function()
print("very fast")
@@ -130,7 +130,7 @@ describe('print', function()
-- loop until we know for sure the callback has been executed
while not done do
os.execute(cmd)
- vim.loop.run("nowait") -- fake os_breakcheck()
+ vim.uv.run("nowait") -- fake os_breakcheck()
end
print("very slow")
vim.api.nvim_command("sleep 1m") -- force deferred event processing
diff --git a/test/functional/lua/thread_spec.lua b/test/functional/lua/thread_spec.lua
index c7f2783cf3..e79d26a641 100644
--- a/test/functional/lua/thread_spec.lua
+++ b/test/functional/lua/thread_spec.lua
@@ -27,10 +27,10 @@ describe('thread', function()
it('entry func is executed in protected mode', function()
exec_lua [[
- local thread = vim.loop.new_thread(function()
+ local thread = vim.uv.new_thread(function()
error('Error in thread entry func')
end)
- vim.loop.thread_join(thread)
+ vim.uv.thread_join(thread)
]]
screen:expect([[
@@ -51,17 +51,17 @@ describe('thread', function()
it('callback is executed in protected mode', function()
exec_lua [[
- local thread = vim.loop.new_thread(function()
- local timer = vim.loop.new_timer()
+ local thread = vim.uv.new_thread(function()
+ local timer = vim.uv.new_timer()
local function ontimeout()
timer:stop()
timer:close()
error('Error in thread callback')
end
timer:start(10, 0, ontimeout)
- vim.loop.run()
+ vim.uv.run()
end)
- vim.loop.thread_join(thread)
+ vim.uv.thread_join(thread)
]]
screen:expect([[
@@ -83,10 +83,10 @@ describe('thread', function()
describe('print', function()
it('works', function()
exec_lua [[
- local thread = vim.loop.new_thread(function()
+ local thread = vim.uv.new_thread(function()
print('print in thread')
end)
- vim.loop.thread_join(thread)
+ vim.uv.thread_join(thread)
]]
screen:expect([[
@@ -105,10 +105,10 @@ describe('thread', function()
it('vim.inspect', function()
exec_lua [[
- local thread = vim.loop.new_thread(function()
+ local thread = vim.uv.new_thread(function()
print(vim.inspect({1,2}))
end)
- vim.loop.thread_join(thread)
+ vim.uv.thread_join(thread)
]]
screen:expect([[
@@ -140,13 +140,13 @@ describe('thread', function()
function Thread_Test:do_test()
local async
local on_async = self.on_async
- async = vim.loop.new_async(function(ret)
+ async = vim.uv.new_async(function(ret)
on_async(ret)
async:close()
end)
local thread =
- vim.loop.new_thread(self.entry_func, async, self.entry_str, self.args)
- vim.loop.thread_join(thread)
+ vim.uv.new_thread(self.entry_func, async, self.entry_str, self.args)
+ vim.uv.thread_join(thread)
end
Thread_Test.new = function(entry, on_async, ...)
@@ -175,10 +175,10 @@ describe('thread', function()
eq({'notification', 'result', {true}}, next_msg())
end)
- it('loop', function()
+ it('uv', function()
exec_lua [[
local entry = function(async)
- async:send(vim.loop.version())
+ async:send(vim.uv.version())
end
local on_async = function(ret)
vim.rpcnotify(1, ret)
@@ -259,7 +259,7 @@ describe('threadpool', function()
local after_work_fn = function(ret)
vim.rpcnotify(1, 'result', ret)
end
- local work = vim.loop.new_work(work_fn, after_work_fn)
+ local work = vim.uv.new_work(work_fn, after_work_fn)
work:queue()
]]
@@ -268,7 +268,7 @@ describe('threadpool', function()
it('with invalid argument', function()
local status = pcall_err(exec_lua, [[
- local work = vim.loop.new_thread(function() end, function() end)
+ local work = vim.uv.new_thread(function() end, function() end)
work:queue({})
]])
@@ -288,7 +288,7 @@ describe('threadpool', function()
})
exec_lua [[
- local work = vim.loop.new_work(function() return {} end, function() end)
+ local work = vim.uv.new_work(function() return {} end, function() end)
work:queue()
]]
@@ -319,7 +319,7 @@ describe('threadpool', function()
function Threadpool_Test:do_test()
local work =
- vim.loop.new_work(self.work_fn, self.after_work)
+ vim.uv.new_work(self.work_fn, self.after_work)
work:queue(self.work_fn_str, self.args)
end
@@ -334,10 +334,10 @@ describe('threadpool', function()
]]
end)
- it('loop', function()
+ it('uv', function()
exec_lua [[
local work_fn = function()
- return vim.loop.version()
+ return vim.uv.version()
end
local after_work_fn = function(ret)
vim.rpcnotify(1, ret)
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index 978a4fe0b6..55c03e21b3 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -882,7 +882,7 @@ describe('lua stdlib', function()
it('vim.fn is allowed in "fast" context by some functions #18306', function()
exec_lua([[
- local timer = vim.loop.new_timer()
+ local timer = vim.uv.new_timer()
timer:start(0, 0, function()
timer:close()
assert(vim.in_fast_event())
@@ -948,7 +948,7 @@ describe('lua stdlib', function()
})
screen:attach()
exec_lua([[
- timer = vim.loop.new_timer()
+ timer = vim.uv.new_timer()
timer:start(20, 0, function ()
-- notify ok (executed later when safe)
vim.rpcnotify(chan, 'nvim_set_var', 'yy', {3, vim.NIL})
@@ -2481,7 +2481,7 @@ describe('lua stdlib', function()
start_time = get_time()
vim.g.timer_result = false
- timer = vim.loop.new_timer()
+ timer = vim.uv.new_timer()
timer:start(100, 0, vim.schedule_wrap(function()
vim.g.timer_result = true
end))
@@ -2503,7 +2503,7 @@ describe('lua stdlib', function()
start_time = get_time()
vim.g.timer_result = false
- timer = vim.loop.new_timer()
+ timer = vim.uv.new_timer()
timer:start(100, 0, vim.schedule_wrap(function()
vim.g.timer_result = true
end))
@@ -2546,17 +2546,17 @@ describe('lua stdlib', function()
it('should allow waiting with no callback, explicit', function()
eq(true, exec_lua [[
- local start_time = vim.loop.hrtime()
+ local start_time = vim.uv.hrtime()
vim.wait(50, nil)
- return vim.loop.hrtime() - start_time > 25000
+ return vim.uv.hrtime() - start_time > 25000
]])
end)
it('should allow waiting with no callback, implicit', function()
eq(true, exec_lua [[
- local start_time = vim.loop.hrtime()
+ local start_time = vim.uv.hrtime()
vim.wait(50)
- return vim.loop.hrtime() - start_time > 25000
+ return vim.uv.hrtime() - start_time > 25000
]])
end)
diff --git a/test/functional/plugin/lsp/helpers.lua b/test/functional/plugin/lsp/helpers.lua
index 86f7da0d2c..15e6a62781 100644
--- a/test/functional/plugin/lsp/helpers.lua
+++ b/test/functional/plugin/lsp/helpers.lua
@@ -99,7 +99,7 @@ local function fake_lsp_server_setup(test_name, timeout_ms, options, settings)
end;
});
workspace_folders = {{
- uri = 'file://' .. vim.loop.cwd(),
+ uri = 'file://' .. vim.uv.cwd(),
name = 'test_folder',
}};
on_init = function(client, result)
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index e0ce62c0db..26fd2276fd 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -65,7 +65,7 @@ describe('LSP', function()
vim.v.progpath, '-l', fake_lsp_code, test_name;
};
workspace_folders = {{
- uri = 'file://' .. vim.loop.cwd(),
+ uri = 'file://' .. vim.uv.cwd(),
name = 'test_folder',
}};
}
@@ -218,6 +218,34 @@ describe('LSP', function()
})
end)
+ it("should set the client's offset_encoding when positionEncoding capability is supported", function()
+ clear()
+ exec_lua(create_server_definition)
+ local result = exec_lua([[
+ local server = _create_server({
+ capabilities = {
+ positionEncoding = "utf-8"
+ },
+ })
+
+ local client_id = vim.lsp.start({
+ name = 'dummy',
+ cmd = server.cmd,
+ })
+
+ if not client_id then
+ return 'vim.lsp.start did not return client_id'
+ end
+
+ local client = vim.lsp.get_client_by_id(client_id)
+ if not client then
+ return 'No client found with id ' .. client_id
+ end
+ return client.offset_encoding
+ ]])
+ eq('utf-8', result)
+ end)
+
it('should succeed with manual shutdown', function()
if is_ci() then
pending('hangs the build on CI #14028, re-enable with freeze timeout #14204')
@@ -2031,7 +2059,7 @@ describe('LSP', function()
}
}
exec_lua('vim.lsp.util.apply_workspace_edit(...)', edit, 'utf-16')
- eq(true, exec_lua('return vim.loop.fs_stat(...) ~= nil', tmpfile))
+ eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', tmpfile))
end)
it('Supports file creation in folder that needs to be created with CreateFile payload', function()
local tmpfile = helpers.tmpname()
@@ -2047,7 +2075,7 @@ describe('LSP', function()
}
}
exec_lua('vim.lsp.util.apply_workspace_edit(...)', edit, 'utf-16')
- eq(true, exec_lua('return vim.loop.fs_stat(...) ~= nil', tmpfile))
+ eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', tmpfile))
end)
it('createFile does not touch file if it exists and ignoreIfExists is set', function()
local tmpfile = helpers.tmpname()
@@ -2065,7 +2093,7 @@ describe('LSP', function()
}
}
exec_lua('vim.lsp.util.apply_workspace_edit(...)', edit, 'utf-16')
- eq(true, exec_lua('return vim.loop.fs_stat(...) ~= nil', tmpfile))
+ eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', tmpfile))
eq('Dummy content', read_file(tmpfile))
end)
it('createFile overrides file if overwrite is set', function()
@@ -2085,7 +2113,7 @@ describe('LSP', function()
}
}
exec_lua('vim.lsp.util.apply_workspace_edit(...)', edit, 'utf-16')
- eq(true, exec_lua('return vim.loop.fs_stat(...) ~= nil', tmpfile))
+ eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', tmpfile))
eq('', read_file(tmpfile))
end)
it('DeleteFile delete file and buffer', function()
@@ -2106,7 +2134,7 @@ describe('LSP', function()
}
}
eq(true, pcall(exec_lua, 'vim.lsp.util.apply_workspace_edit(...)', edit, 'utf-16'))
- eq(false, exec_lua('return vim.loop.fs_stat(...) ~= nil', tmpfile))
+ eq(false, exec_lua('return vim.uv.fs_stat(...) ~= nil', tmpfile))
eq(false, exec_lua('return vim.api.nvim_buf_is_loaded(vim.fn.bufadd(...))', tmpfile))
end)
it('DeleteFile fails if file does not exist and ignoreIfNotExists is false', function()
@@ -2125,7 +2153,7 @@ describe('LSP', function()
}
}
eq(false, pcall(exec_lua, 'vim.lsp.util.apply_workspace_edit(...)', edit))
- eq(false, exec_lua('return vim.loop.fs_stat(...) ~= nil', tmpfile))
+ eq(false, exec_lua('return vim.uv.fs_stat(...) ~= nil', tmpfile))
end)
end)
@@ -2195,9 +2223,9 @@ describe('LSP', function()
return vim.api.nvim_buf_get_lines(bufnr, 0, -1, true)
]], old, new)
eq({'Test content'}, lines)
- local exists = exec_lua('return vim.loop.fs_stat(...) ~= nil', old)
+ local exists = exec_lua('return vim.uv.fs_stat(...) ~= nil', old)
eq(false, exists)
- exists = exec_lua('return vim.loop.fs_stat(...) ~= nil', new)
+ exists = exec_lua('return vim.uv.fs_stat(...) ~= nil', new)
eq(true, exists)
os.remove(new)
end)
@@ -2238,9 +2266,9 @@ describe('LSP', function()
return vim.fn.bufloaded(oldbufnr)
]], old_dir, new_dir, pathsep)
eq(0, lines)
- eq(false, exec_lua('return vim.loop.fs_stat(...) ~= nil', old_dir))
- eq(true, exec_lua('return vim.loop.fs_stat(...) ~= nil', new_dir))
- eq(true, exec_lua('return vim.loop.fs_stat(...) ~= nil', new_dir .. pathsep .. file))
+ eq(false, exec_lua('return vim.uv.fs_stat(...) ~= nil', old_dir))
+ eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', new_dir))
+ eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', new_dir .. pathsep .. file))
eq('Test content', read_file(new_dir .. pathsep .. file))
os.remove(new_dir)
@@ -2258,7 +2286,7 @@ describe('LSP', function()
vim.lsp.util.rename(old, new, { ignoreIfExists = true })
]], old, new)
- eq(true, exec_lua('return vim.loop.fs_stat(...) ~= nil', old))
+ eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', old))
eq('New file', read_file(new))
exec_lua([[
@@ -2268,7 +2296,7 @@ describe('LSP', function()
vim.lsp.util.rename(old, new, { overwrite = false })
]], old, new)
- eq(true, exec_lua('return vim.loop.fs_stat(...) ~= nil', old))
+ eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', old))
eq('New file', read_file(new))
end)
it('Does override target if overwrite is true', function()
@@ -2283,8 +2311,8 @@ describe('LSP', function()
vim.lsp.util.rename(old, new, { overwrite = true })
]], old, new)
- eq(false, exec_lua('return vim.loop.fs_stat(...) ~= nil', old))
- eq(true, exec_lua('return vim.loop.fs_stat(...) ~= nil', new))
+ eq(false, exec_lua('return vim.uv.fs_stat(...) ~= nil', old))
+ eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', new))
eq('Old file\n', read_file(new))
end)
end)
@@ -3669,7 +3697,7 @@ describe('LSP', function()
describe('cmd', function()
it('can connect to lsp server via rpc.connect', function()
local result = exec_lua [[
- local uv = vim.loop
+ local uv = vim.uv
local server = uv.new_tcp()
local init = nil
server:bind('127.0.0.1', 0)
@@ -3697,7 +3725,7 @@ describe('LSP', function()
describe('handlers', function()
it('handler can return false as response', function()
local result = exec_lua [[
- local uv = vim.loop
+ local uv = vim.uv
local server = uv.new_tcp()
local messages = {}
local responses = {}
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 1b65c1cddc..7723b6c7e7 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -1554,7 +1554,7 @@ describe('TUI', function()
end)
it('no assert failure on deadly signal #21896', function()
- exec_lua([[vim.loop.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]])
+ exec_lua([[vim.uv.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]])
screen:expect({any = '%[Process exited 1%]'})
end)
@@ -1605,7 +1605,7 @@ describe('TUI', function()
foo |
{3:-- TERMINAL --} |
]])
- exec_lua([[vim.loop.kill(vim.fn.jobpid(vim.bo.channel), 'sigwinch')]])
+ exec_lua([[vim.uv.kill(vim.fn.jobpid(vim.bo.channel), 'sigwinch')]])
screen:expect([[
{1: } |
{4:~ }|
@@ -2517,7 +2517,7 @@ describe("TUI as a client", function()
-- No heap-use-after-free when receiving UI events after deadly signal #22184
server:request('nvim_input', ('a'):rep(1000))
- exec_lua([[vim.loop.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]])
+ exec_lua([[vim.uv.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]])
screen:expect({any = '%[Process exited 1%]'})
eq(0, meths.get_vvar('shell_error'))
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua
index 14de07639b..e463382d07 100644
--- a/test/functional/treesitter/parser_spec.lua
+++ b/test/functional/treesitter/parser_spec.lua
@@ -182,11 +182,11 @@ void ui_refresh(void)
local function q(n)
return exec_lua ([[
local query, n = ...
- local before = vim.loop.hrtime()
+ local before = vim.uv.hrtime()
for i=1,n,1 do
cquery = vim.treesitter.query.parse("c", ...)
end
- local after = vim.loop.hrtime()
+ local after = vim.uv.hrtime()
return after - before
]], long_query, n)
end
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 54441984a3..cbf0178d28 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -666,6 +666,7 @@ describe('extmark decorations', function()
[30] = {foreground = Screen.colors.DarkCyan, background = Screen.colors.LightGray, underline = true};
[31] = {underline = true, foreground = Screen.colors.DarkCyan};
[32] = {underline = true};
+ [33] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray};
}
ns = meths.create_namespace 'test'
@@ -1147,6 +1148,46 @@ describe('extmark decorations', function()
]]}
end)
+ it('can have virtual text on folded line', function()
+ insert([[
+ 11111
+ 22222
+ 33333]])
+ command('1,2fold')
+ command('set nowrap')
+ screen:try_resize(50, 3)
+ feed('zb')
+ -- XXX: the behavior of overlay virtual text at non-zero column is strange:
+ -- 1. With 'wrap' it is never shown.
+ -- 2. With 'nowrap' it is shown only if the extmark is hidden before leftcol.
+ meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'overlay' })
+ meths.buf_set_extmark(0, ns, 0, 1, { virt_text = {{'BB', 'Underlined'}}, hl_mode = 'combine', virt_text_win_col = 10 })
+ meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'CC', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'right_align' })
+ screen:expect{grid=[[
+ {29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}|
+ 3333^3 |
+ |
+ ]]}
+ feed('zl')
+ screen:expect{grid=[[
+ {29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}|
+ 333^3 |
+ |
+ ]]}
+ feed('zl')
+ screen:expect{grid=[[
+ {29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}|
+ 33^3 |
+ |
+ ]]}
+ feed('zl')
+ screen:expect{grid=[[
+ {29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}|
+ 3^3 |
+ |
+ ]]}
+ end)
+
it('can have virtual text which combines foreground and background groups', function()
screen:set_default_attr_ids {
[1] = {bold=true, foreground=Screen.colors.Blue};
diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua
index 630d0d0948..d18e19e5b2 100644
--- a/test/functional/ui/spell_spec.lua
+++ b/test/functional/ui/spell_spec.lua
@@ -178,6 +178,30 @@ describe("'spell'", function()
{0:~ }|
|
]])
+ -- Adding an empty line does not remove Cap in "mod_bot" area
+ feed('zbO<Esc>')
+ screen:expect([[
+ This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
+ ^ |
+ {2:another} missing cap here |
+ {10:+-- 2 lines: Not·······························································}|
+ {2:and} here. |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]])
+ -- Multiple empty lines does not remove Cap in the line after
+ feed('O<Esc><C-L>')
+ screen:expect([[
+ This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
+ ^ |
+ |
+ {2:another} missing cap here |
+ {10:+-- 2 lines: Not·······························································}|
+ {2:and} here. |
+ {0:~ }|
+ |
+ ]])
end)
-- oldtest: Test_spell_compatible()
diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim
index 41a8610893..177fef9e99 100644
--- a/test/old/testdir/test_functions.vim
+++ b/test/old/testdir/test_functions.vim
@@ -2834,6 +2834,34 @@ func Test_screen_functions()
call assert_equal(-1, screenattr(-1, -1))
call assert_equal(-1, screenchar(-1, -1))
call assert_equal([], screenchars(-1, -1))
+
+ " Run this in a separate Vim instance to avoid messing up.
+ let after =<< trim [CODE]
+ scriptencoding utf-8
+ call setline(1, '口')
+ redraw
+ call assert_equal(0, screenattr(1, 1))
+ call assert_equal(char2nr('口'), screenchar(1, 1))
+ call assert_equal([char2nr('口')], screenchars(1, 1))
+ call assert_equal('口', screenstring(1, 1))
+ call writefile(v:errors, 'Xresult')
+ qall!
+ [CODE]
+
+ let encodings = ['utf-8', 'cp932', 'cp936', 'cp949', 'cp950']
+ if !has('win32')
+ let encodings += ['euc-jp']
+ endif
+ if has('nvim')
+ let encodings = ['utf-8']
+ endif
+ for enc in encodings
+ let msg = 'enc=' .. enc
+ if RunVim([], after, $'--clean --cmd "set encoding={enc}"')
+ call assert_equal([], readfile('Xresult'), msg)
+ endif
+ call delete('Xresult')
+ endfor
endfunc
" Test for getcurpos() and setpos()
diff --git a/test/old/testdir/test_put.vim b/test/old/testdir/test_put.vim
index 212a979b4a..6c4bd28386 100644
--- a/test/old/testdir/test_put.vim
+++ b/test/old/testdir/test_put.vim
@@ -266,5 +266,23 @@ func Test_put_other_window()
call StopVimInTerminal(buf)
endfunc
+func Test_put_in_last_displayed_line()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ vim9script
+ autocmd CursorMoved * eval line('w$')
+ @a = 'x'->repeat(&columns * 2 - 2)
+ range(&lines)->setline(1)
+ feedkeys('G"ap')
+ END
+ call writefile(lines, 'Xtest_put_last_line', 'D')
+ let buf = RunVimInTerminal('-S Xtest_put_last_line', #{rows: 10})
+
+ call VerifyScreenDump(buf, 'Test_put_in_last_displayed_line_1', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_registers.vim b/test/old/testdir/test_registers.vim
index bbf1aa53b5..70dac535b4 100644
--- a/test/old/testdir/test_registers.vim
+++ b/test/old/testdir/test_registers.vim
@@ -55,8 +55,9 @@ func Test_display_registers()
call feedkeys("i\<C-R>=2*4\n\<esc>")
call feedkeys(":ls\n", 'xt')
- let a = execute('display')
- let b = execute('registers')
+ " these commands work in the sandbox
+ let a = execute('sandbox display')
+ let b = execute('sandbox registers')
call assert_equal(a, b)
call assert_match('^\nType Name Content\n'
diff --git a/test/old/testdir/test_spell.vim b/test/old/testdir/test_spell.vim
index b0b2668758..59b433d6e1 100644
--- a/test/old/testdir/test_spell.vim
+++ b/test/old/testdir/test_spell.vim
@@ -962,6 +962,7 @@ func Test_spell_screendump()
CheckScreendump
let lines =<< trim END
+ call test_override('alloc_lines', 1)
call setline(1, [
\ "This is some text without any spell errors. Everything",
\ "should just be black, nothing wrong here.",
@@ -984,6 +985,7 @@ func Test_spell_screendump_spellcap()
CheckScreendump
let lines =<< trim END
+ call test_override('alloc_lines', 1)
call setline(1, [
\ " This line has a sepll error. and missing caps and trailing spaces. ",
\ "another missing cap here.",
@@ -1023,6 +1025,14 @@ func Test_spell_screendump_spellcap()
call term_sendkeys(buf, "\<C-E>\<C-L>")
call VerifyScreenDump(buf, 'Test_spell_8', {})
+ " Adding an empty line does not remove Cap in "mod_bot" area
+ call term_sendkeys(buf, "zbO\<Esc>")
+ call VerifyScreenDump(buf, 'Test_spell_9', {})
+
+ " Multiple empty lines does not remove Cap in the line after
+ call term_sendkeys(buf, "O\<Esc>\<C-L>")
+ call VerifyScreenDump(buf, 'Test_spell_10', {})
+
" clean up
call StopVimInTerminal(buf)
endfunc
@@ -1031,6 +1041,7 @@ func Test_spell_compatible()
CheckScreendump
let lines =<< trim END
+ call test_override('alloc_lines', 1)
call setline(1, [
\ "test "->repeat(20),
\ "",
diff --git a/test/old/testdir/test_utf8.vim b/test/old/testdir/test_utf8.vim
index 00b060a9e2..a5a9624ec3 100644
--- a/test/old/testdir/test_utf8.vim
+++ b/test/old/testdir/test_utf8.vim
@@ -88,7 +88,20 @@ func Test_screenchar_utf8()
call assert_equal("B", screenstring(1, 2))
call assert_equal("C\u0308", screenstring(1, 3))
- " 2-cells, with composing characters
+ " 1-cell, with 6 composing characters
+ set maxcombine=6
+ call setline(1, ["ABC" .. repeat("\u0308", 6)])
+ redraw
+ call assert_equal([0x0041], screenchars(1, 1))
+ call assert_equal([0x0042], 1->screenchars(2))
+ " This should not use uninitialized memory
+ call assert_equal([0x0043] + repeat([0x0308], 6), screenchars(1, 3))
+ call assert_equal("A", screenstring(1, 1))
+ call assert_equal("B", screenstring(1, 2))
+ call assert_equal("C" .. repeat("\u0308", 6), screenstring(1, 3))
+ set maxcombine&
+
+ " 2-cells, with composing characters
let text = "\u3042\u3044\u3046\u3099"
call setline(1, text)
redraw
diff --git a/test/old/testdir/test_window_cmd.vim b/test/old/testdir/test_window_cmd.vim
index d4ff241366..7d4932a2b5 100644
--- a/test/old/testdir/test_window_cmd.vim
+++ b/test/old/testdir/test_window_cmd.vim
@@ -1763,9 +1763,20 @@ endfunc
func Test_splitkeep_misc()
set splitkeep=screen
- set splitbelow
call setline(1, range(1, &lines))
+ " Cursor is adjusted to start and end of buffer
+ norm M
+ wincmd s
+ resize 1
+ call assert_equal(1, line('.'))
+ wincmd j
+ norm GM
+ resize 1
+ call assert_equal(&lines, line('.'))
+ only!
+
+ set splitbelow
norm Gzz
let top = line('w0')
" No scroll when aucmd_win is opened