aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/lua/vim_spec.lua44
-rw-r--r--test/functional/terminal/scrollback_spec.lua19
-rw-r--r--test/functional/ui/decorations_spec.lua52
-rw-r--r--test/functional/ui/float_spec.lua12
4 files changed, 63 insertions, 64 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index 4f401eed8f..9508469a61 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -2721,11 +2721,11 @@ describe('lua stdlib', function()
it('does not cause ml_get errors with invalid visual selection', function()
-- Should be fixed by vim-patch:8.2.4028.
exec_lua [[
- local a = vim.api
- local t = function(s) return a.nvim_replace_termcodes(s, true, true, true) end
- a.nvim_buf_set_lines(0, 0, -1, true, {"a", "b", "c"})
- a.nvim_feedkeys(t "G<C-V>", "txn", false)
- a.nvim_buf_call(a.nvim_create_buf(false, true), function() vim.cmd "redraw" end)
+ local api = vim.api
+ local t = function(s) return api.nvim_replace_termcodes(s, true, true, true) end
+ api.nvim_buf_set_lines(0, 0, -1, true, {"a", "b", "c"})
+ api.nvim_feedkeys(t "G<C-V>", "txn", false)
+ api.nvim_buf_call(api.nvim_create_buf(false, true), function() vim.cmd "redraw" end)
]]
end)
@@ -2800,29 +2800,29 @@ describe('lua stdlib', function()
it('does not cause ml_get errors with invalid visual selection', function()
-- Add lines to the current buffer and make another window looking into an empty buffer.
exec_lua [[
- _G.a = vim.api
- _G.t = function(s) return a.nvim_replace_termcodes(s, true, true, true) end
- _G.win_lines = a.nvim_get_current_win()
+ _G.api = vim.api
+ _G.t = function(s) return api.nvim_replace_termcodes(s, true, true, true) end
+ _G.win_lines = api.nvim_get_current_win()
vim.cmd "new"
- _G.win_empty = a.nvim_get_current_win()
- a.nvim_set_current_win(win_lines)
- a.nvim_buf_set_lines(0, 0, -1, true, {"a", "b", "c"})
+ _G.win_empty = api.nvim_get_current_win()
+ api.nvim_set_current_win(win_lines)
+ api.nvim_buf_set_lines(0, 0, -1, true, {"a", "b", "c"})
]]
-- Start Visual in current window, redraw in other window with fewer lines.
-- Should be fixed by vim-patch:8.2.4018.
exec_lua [[
- a.nvim_feedkeys(t "G<C-V>", "txn", false)
- a.nvim_win_call(win_empty, function() vim.cmd "redraw" end)
+ api.nvim_feedkeys(t "G<C-V>", "txn", false)
+ api.nvim_win_call(win_empty, function() vim.cmd "redraw" end)
]]
-- Start Visual in current window, extend it in other window with more lines.
-- Fixed for win_execute by vim-patch:8.2.4026, but nvim_win_call should also not be affected.
exec_lua [[
- a.nvim_feedkeys(t "<Esc>gg", "txn", false)
- a.nvim_set_current_win(win_empty)
- a.nvim_feedkeys(t "gg<C-V>", "txn", false)
- a.nvim_win_call(win_lines, function() a.nvim_feedkeys(t "G<C-V>", "txn", false) end)
+ api.nvim_feedkeys(t "<Esc>gg", "txn", false)
+ api.nvim_set_current_win(win_empty)
+ api.nvim_feedkeys(t "gg<C-V>", "txn", false)
+ api.nvim_win_call(win_lines, function() api.nvim_feedkeys(t "G<C-V>", "txn", false) end)
vim.cmd "redraw"
]]
end)
@@ -2836,14 +2836,14 @@ describe('lua stdlib', function()
}
screen:attach()
exec_lua [[
- _G.a = vim.api
+ _G.api = vim.api
vim.opt.ruler = true
local lines = {}
for i = 0, 499 do lines[#lines + 1] = tostring(i) end
- a.nvim_buf_set_lines(0, 0, -1, true, lines)
- a.nvim_win_set_cursor(0, {20, 0})
+ api.nvim_buf_set_lines(0, 0, -1, true, lines)
+ api.nvim_win_set_cursor(0, {20, 0})
vim.cmd "split"
- _G.win = a.nvim_get_current_win()
+ _G.win = api.nvim_get_current_win()
vim.cmd "wincmd w | redraw"
]]
screen:expect [[
@@ -2854,7 +2854,7 @@ describe('lua stdlib', function()
|
]]
exec_lua [[
- a.nvim_win_call(win, function() a.nvim_win_set_cursor(0, {100, 0}) end)
+ api.nvim_win_call(win, function() api.nvim_win_set_cursor(0, {100, 0}) end)
vim.cmd "redraw"
]]
screen:expect [[
diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua
index 00a35a5c6c..5d967e0340 100644
--- a/test/functional/terminal/scrollback_spec.lua
+++ b/test/functional/terminal/scrollback_spec.lua
@@ -575,12 +575,12 @@ describe("pending scrollback line handling", function()
it("does not crash after setting 'number' #14891", function()
exec_lua [[
- local a = vim.api
- local buf = a.nvim_create_buf(true, true)
- local chan = a.nvim_open_term(buf, {})
- a.nvim_win_set_option(0, "number", true)
- a.nvim_chan_send(chan, ("a\n"):rep(11) .. "a")
- a.nvim_win_set_buf(0, buf)
+ local api = vim.api
+ local buf = api.nvim_create_buf(true, true)
+ local chan = api.nvim_open_term(buf, {})
+ api.nvim_win_set_option(0, "number", true)
+ api.nvim_chan_send(chan, ("a\n"):rep(11) .. "a")
+ api.nvim_win_set_buf(0, buf)
]]
screen:expect [[
{1: 1 }^a |
@@ -607,12 +607,11 @@ describe("pending scrollback line handling", function()
it("does not crash after nvim_buf_call #14891", function()
skip(is_os('win'))
exec_lua [[
- local a = vim.api
- local bufnr = a.nvim_create_buf(false, true)
- a.nvim_buf_call(bufnr, function()
+ local bufnr = vim.api.nvim_create_buf(false, true)
+ vim.api.nvim_buf_call(bufnr, function()
vim.fn.termopen({"echo", ("hi\n"):rep(11)})
end)
- a.nvim_win_set_buf(0, bufnr)
+ vim.api.nvim_win_set_buf(0, bufnr)
vim.cmd("startinsert")
]]
screen:expect [[
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index d03d2f1374..80e5b6230e 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -47,15 +47,15 @@ describe('decorations providers', function()
local function setup_provider(code)
return exec_lua ([[
- local a = vim.api
- _G.ns1 = a.nvim_create_namespace "ns1"
+ local api = vim.api
+ _G.ns1 = api.nvim_create_namespace "ns1"
]] .. (code or [[
beamtrace = {}
local function on_do(kind, ...)
table.insert(beamtrace, {kind, ...})
end
]]) .. [[
- a.nvim_set_decoration_provider(_G.ns1, {
+ api.nvim_set_decoration_provider(_G.ns1, {
on_start = on_do; on_buf = on_do;
on_win = on_do; on_line = on_do;
on_end = on_do; _on_spell_nav = on_do;
@@ -75,8 +75,8 @@ describe('decorations providers', function()
-- rather than append, which used to spin in an infinite loop allocating
-- memory until nvim crashed/was killed.
setup_provider([[
- local ns2 = a.nvim_create_namespace "ns2"
- a.nvim_set_decoration_provider(ns2, {})
+ local ns2 = api.nvim_create_namespace "ns2"
+ api.nvim_set_decoration_provider(ns2, {})
]])
helpers.assert_alive()
end)
@@ -132,12 +132,12 @@ describe('decorations providers', function()
it('can have single provider', function()
insert(mulholland)
setup_provider [[
- local hl = a.nvim_get_hl_id_by_name "ErrorMsg"
- local test_ns = a.nvim_create_namespace "mulholland"
+ local hl = api.nvim_get_hl_id_by_name "ErrorMsg"
+ local test_ns = api.nvim_create_namespace "mulholland"
function on_do(event, ...)
if event == "line" then
local win, buf, line = ...
- a.nvim_buf_set_extmark(buf, test_ns, line, line,
+ api.nvim_buf_set_extmark(buf, test_ns, line, line,
{ end_line = line, end_col = line+1,
hl_group = hl,
ephemeral = true
@@ -172,11 +172,11 @@ describe('decorations providers', function()
]]
setup_provider [[
- local ns = a.nvim_create_namespace "spell"
+ local ns = api.nvim_create_namespace "spell"
beamtrace = {}
local function on_do(kind, ...)
if kind == 'win' or kind == 'spell' then
- a.nvim_buf_set_extmark(0, ns, 0, 0, {
+ api.nvim_buf_set_extmark(0, ns, 0, 0, {
end_row = 2,
end_col = 23,
spell = true,
@@ -330,12 +330,12 @@ describe('decorations providers', function()
]]}
exec_lua [[
- local a = vim.api
- local thewin = a.nvim_get_current_win()
- local ns2 = a.nvim_create_namespace 'ns2'
- a.nvim_set_decoration_provider (ns2, {
+ local api = vim.api
+ local thewin = api.nvim_get_current_win()
+ local ns2 = api.nvim_create_namespace 'ns2'
+ api.nvim_set_decoration_provider (ns2, {
on_win = function (_, win, buf)
- a.nvim_set_hl_ns_fast(win == thewin and _G.ns1 or ns2)
+ api.nvim_set_hl_ns_fast(win == thewin and _G.ns1 or ns2)
end;
})
]]
@@ -436,12 +436,12 @@ describe('decorations providers', function()
it('can have virtual text', function()
insert(mulholland)
setup_provider [[
- local hl = a.nvim_get_hl_id_by_name "ErrorMsg"
- local test_ns = a.nvim_create_namespace "mulholland"
+ local hl = api.nvim_get_hl_id_by_name "ErrorMsg"
+ local test_ns = api.nvim_create_namespace "mulholland"
function on_do(event, ...)
if event == "line" then
local win, buf, line = ...
- a.nvim_buf_set_extmark(buf, test_ns, line, 0, {
+ api.nvim_buf_set_extmark(buf, test_ns, line, 0, {
virt_text = {{'+', 'ErrorMsg'}};
virt_text_pos='overlay';
ephemeral = true;
@@ -465,12 +465,12 @@ describe('decorations providers', function()
it('can have virtual text of the style: right_align', function()
insert(mulholland)
setup_provider [[
- local hl = a.nvim_get_hl_id_by_name "ErrorMsg"
- local test_ns = a.nvim_create_namespace "mulholland"
+ local hl = api.nvim_get_hl_id_by_name "ErrorMsg"
+ local test_ns = api.nvim_create_namespace "mulholland"
function on_do(event, ...)
if event == "line" then
local win, buf, line = ...
- a.nvim_buf_set_extmark(buf, test_ns, line, 0, {
+ api.nvim_buf_set_extmark(buf, test_ns, line, 0, {
virt_text = {{'+'}, {string.rep(' ', line+1), 'ErrorMsg'}};
virt_text_pos='right_align';
ephemeral = true;
@@ -494,12 +494,12 @@ describe('decorations providers', function()
it('can highlight beyond EOL', function()
insert(mulholland)
setup_provider [[
- local test_ns = a.nvim_create_namespace "veberod"
+ local test_ns = api.nvim_create_namespace "veberod"
function on_do(event, ...)
if event == "line" then
local win, buf, line = ...
- if string.find(a.nvim_buf_get_lines(buf, line, line+1, true)[1], "buf") then
- a.nvim_buf_set_extmark(buf, test_ns, line, 0, {
+ if string.find(api.nvim_buf_get_lines(buf, line, line+1, true)[1], "buf") then
+ api.nvim_buf_set_extmark(buf, test_ns, line, 0, {
end_line = line+1;
hl_group = 'DiffAdd';
hl_eol = true;
@@ -534,9 +534,9 @@ describe('decorations providers', function()
local function on_do(kind, winid, bufnr, topline, botline_guess)
if kind == 'win' then
if topline < 100 and botline_guess > 100 then
- vim.api.nvim_buf_set_extmark(bufnr, ns1, 99, -1, { sign_text = 'X' })
+ api.nvim_buf_set_extmark(bufnr, ns1, 99, -1, { sign_text = 'X' })
else
- vim.api.nvim_buf_clear_namespace(bufnr, ns1, 0, -1)
+ api.nvim_buf_clear_namespace(bufnr, ns1, 0, -1)
end
end
end
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 32f28dce26..4612ffe56f 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -65,20 +65,20 @@ describe('float window', function()
it('closed immediately by autocmd #11383', function()
eq('Window was closed immediately',
pcall_err(exec_lua, [[
- local a = vim.api
+ local api = vim.api
local function crashes(contents)
- local buf = a.nvim_create_buf(false, true)
- local floatwin = a.nvim_open_win(buf, true, {
+ local buf = api.nvim_create_buf(false, true)
+ local floatwin = api.nvim_open_win(buf, true, {
relative = 'cursor';
style = 'minimal';
row = 0; col = 0;
height = #contents;
width = 10;
})
- a.nvim_buf_set_lines(buf, 0, -1, true, contents)
+ api.nvim_buf_set_lines(buf, 0, -1, true, contents)
local winnr = vim.fn.win_id2win(floatwin)
- a.nvim_command('wincmd p')
- a.nvim_command('autocmd CursorMoved * ++once '..winnr..'wincmd c')
+ api.nvim_command('wincmd p')
+ api.nvim_command('autocmd CursorMoved * ++once '..winnr..'wincmd c')
return buf, floatwin
end
crashes{'foo'}