aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/api/highlight_spec.lua95
-rw-r--r--test/functional/eval/null_spec.lua1
-rw-r--r--test/functional/legacy/packadd_spec.lua2
-rw-r--r--test/functional/lua/buffer_updates_spec.lua45
-rw-r--r--test/functional/lua/vim_spec.lua16
-rw-r--r--test/functional/plugin/lsp_spec.lua139
-rw-r--r--test/functional/treesitter/parser_spec.lua96
-rw-r--r--test/functional/ui/float_spec.lua104
-rw-r--r--test/functional/ui/screen.lua29
9 files changed, 393 insertions, 134 deletions
diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua
index 058706718a..21e3094f8e 100644
--- a/test/functional/api/highlight_spec.lua
+++ b/test/functional/api/highlight_spec.lua
@@ -158,3 +158,98 @@ describe('API: highlight',function()
assert_alive()
end)
end)
+
+describe("API: set highlight", function()
+ local highlight_color = {
+ fg = tonumber('0xff0000'),
+ bg = tonumber('0x0032aa'),
+ ctermfg = 8,
+ ctermbg = 15,
+ }
+ local highlight1 = {
+ background = highlight_color.bg,
+ foreground = highlight_color.fg,
+ bold = true,
+ italic = true,
+ }
+ local highlight2_config = {
+ ctermbg = highlight_color.ctermbg,
+ ctermfg = highlight_color.ctermfg,
+ underline = true,
+ reverse = true,
+ }
+ local highlight2_result = {
+ background = highlight_color.ctermbg,
+ foreground = highlight_color.ctermfg,
+ underline = true,
+ reverse = true,
+ }
+ local highlight3_config = {
+ background = highlight_color.bg,
+ foreground = highlight_color.fg,
+ ctermbg = highlight_color.ctermbg,
+ ctermfg = highlight_color.ctermfg,
+ bold = true,
+ italic = true,
+ reverse = true,
+ undercurl = true,
+ underline = true,
+ cterm = {
+ italic = true,
+ reverse = true,
+ undercurl = true,
+ }
+ }
+ local highlight3_result_gui = {
+ background = highlight_color.bg,
+ foreground = highlight_color.fg,
+ bold = true,
+ italic = true,
+ reverse = true,
+ undercurl = true,
+ underline = true,
+ }
+ local highlight3_result_cterm = {
+ background = highlight_color.ctermbg,
+ foreground = highlight_color.ctermfg,
+ italic = true,
+ reverse = true,
+ undercurl = true,
+ }
+
+ local function get_ns()
+ local ns = meths.create_namespace('Test_set_hl')
+ meths._set_hl_ns(ns)
+ return ns
+ end
+
+ before_each(clear)
+
+ it ("can set gui highlight", function()
+ local ns = get_ns()
+ meths.set_hl(ns, 'Test_hl', highlight1)
+ eq(highlight1, meths.get_hl_by_name('Test_hl', true))
+ end)
+
+ it ("can set cterm highlight", function()
+ local ns = get_ns()
+ meths.set_hl(ns, 'Test_hl', highlight2_config)
+ eq(highlight2_result, meths.get_hl_by_name('Test_hl', false))
+ end)
+
+ it ("cterm attr defaults to gui attr", function()
+ local ns = get_ns()
+ meths.set_hl(ns, 'Test_hl', highlight1)
+ eq({
+ bold = true,
+ italic = true,
+ }, meths.get_hl_by_name('Test_hl', false))
+ end)
+
+ it ("can overwrite attr for cterm", function()
+ local ns = get_ns()
+ meths.set_hl(ns, 'Test_hl', highlight3_config)
+ eq(highlight3_result_gui, meths.get_hl_by_name('Test_hl', true))
+ eq(highlight3_result_cterm, meths.get_hl_by_name('Test_hl', false))
+ end)
+end)
diff --git a/test/functional/eval/null_spec.lua b/test/functional/eval/null_spec.lua
index d403fbc878..4f29811095 100644
--- a/test/functional/eval/null_spec.lua
+++ b/test/functional/eval/null_spec.lua
@@ -73,6 +73,7 @@ describe('NULL', function()
null_expr_test('does not crash col()', 'col(L)', 0, 0)
null_expr_test('does not crash virtcol()', 'virtcol(L)', 0, 0)
null_expr_test('does not crash line()', 'line(L)', 0, 0)
+ null_expr_test('does not crash line() with window id', 'line(L, 1000)', 0, 0)
null_expr_test('does not crash count()', 'count(L, 1)', 0, 0)
null_expr_test('does not crash cursor()', 'cursor(L)', 'E474: Invalid argument', -1)
null_expr_test('does not crash map()', 'map(L, "v:val")', 0, {})
diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua
index 609f825177..486a1fe471 100644
--- a/test/functional/legacy/packadd_spec.lua
+++ b/test/functional/legacy/packadd_spec.lua
@@ -267,6 +267,8 @@ describe('packadd', function()
call assert_match('look-here', tags1[0])
let tags2 = readfile(docdir2 . '/tags')
call assert_match('look-away', tags2[0])
+
+ call assert_fails('helptags abcxyz', 'E150:')
endfunc
func Test_colorscheme()
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 5da8452a51..5bfab1d52d 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -936,6 +936,51 @@ describe('lua: nvim_buf_attach on_bytes', function()
}
end)
+ it("block visual paste", function()
+ local check_events = setup_eventcheck(verify, {"AAA",
+ "BBB",
+ "CCC",
+ "DDD",
+ "EEE",
+ "FFF"})
+ funcs.setreg("a", "___")
+ feed([[gg0l<c-v>3jl"ap]])
+
+ check_events {
+ { "test1", "bytes", 1, 3, 0, 1, 1, 0, 2, 2, 0, 0, 0 };
+ { "test1", "bytes", 1, 3, 1, 1, 3, 0, 2, 2, 0, 0, 0 };
+ { "test1", "bytes", 1, 3, 2, 1, 5, 0, 2, 2, 0, 0, 0 };
+ { "test1", "bytes", 1, 3, 3, 1, 7, 0, 2, 2, 0, 0, 0 };
+ { "test1", "bytes", 1, 5, 0, 1, 1, 0, 0, 0, 0, 3, 3 };
+ { "test1", "bytes", 1, 6, 1, 1, 6, 0, 0, 0, 0, 3, 3 };
+ { "test1", "bytes", 1, 7, 2, 1, 11, 0, 0, 0, 0, 3, 3 };
+ { "test1", "bytes", 1, 8, 3, 1, 16, 0, 0, 0, 0, 3, 3 };
+ }
+ end)
+
+ it("nvim_buf_set_lines", function()
+ local check_events = setup_eventcheck(verify, {"AAA", "BBB"})
+
+ -- delete
+ meths.buf_set_lines(0, 0, 1, true, {})
+
+ check_events {
+ { "test1", "bytes", 1, 3, 0, 0, 0, 1, 0, 4, 0, 0, 0 };
+ }
+
+ -- add
+ meths.buf_set_lines(0, 0, 0, true, {'asdf'})
+ check_events {
+ { "test1", "bytes", 1, 4, 0, 0, 0, 0, 0, 0, 1, 0, 5 };
+ }
+
+ -- replace
+ meths.buf_set_lines(0, 0, 1, true, {'asdf', 'fdsa'})
+ check_events {
+ { "test1", "bytes", 1, 5, 0, 0, 0, 1, 0, 5, 2, 0, 10 };
+ }
+ 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 9bf00b594b..6566da4807 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -945,12 +945,20 @@ describe('lua stdlib', function()
exec_lua [[
vim.api.nvim_set_var("testing", "hi")
vim.api.nvim_set_var("other", 123)
+ vim.api.nvim_set_var("floaty", 5120.1)
+ vim.api.nvim_set_var("nullvar", vim.NIL)
vim.api.nvim_set_var("to_delete", {hello="world"})
]]
eq('hi', funcs.luaeval "vim.g.testing")
eq(123, funcs.luaeval "vim.g.other")
+ eq(5120.1, funcs.luaeval "vim.g.floaty")
eq(NIL, funcs.luaeval "vim.g.nonexistant")
+ eq(NIL, funcs.luaeval "vim.g.nullvar")
+ -- lost over RPC, so test locally:
+ eq({false, true}, exec_lua [[
+ return {vim.g.nonexistant == vim.NIL, vim.g.nullvar == vim.NIL}
+ ]])
eq({hello="world"}, funcs.luaeval "vim.g.to_delete")
exec_lua [[
@@ -963,12 +971,20 @@ describe('lua stdlib', function()
exec_lua [[
vim.api.nvim_buf_set_var(0, "testing", "hi")
vim.api.nvim_buf_set_var(0, "other", 123)
+ vim.api.nvim_buf_set_var(0, "floaty", 5120.1)
+ vim.api.nvim_buf_set_var(0, "nullvar", vim.NIL)
vim.api.nvim_buf_set_var(0, "to_delete", {hello="world"})
]]
eq('hi', funcs.luaeval "vim.b.testing")
eq(123, funcs.luaeval "vim.b.other")
+ eq(5120.1, funcs.luaeval "vim.b.floaty")
eq(NIL, funcs.luaeval "vim.b.nonexistant")
+ eq(NIL, funcs.luaeval "vim.b.nullvar")
+ -- lost over RPC, so test locally:
+ eq({false, true}, exec_lua [[
+ return {vim.b.nonexistant == vim.NIL, vim.b.nullvar == vim.NIL}
+ ]])
eq({hello="world"}, funcs.luaeval "vim.b.to_delete")
exec_lua [[
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index c136ae652f..663271deab 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -9,6 +9,7 @@ local eq = helpers.eq
local pcall_err = helpers.pcall_err
local pesc = helpers.pesc
local insert = helpers.insert
+local funcs = helpers.funcs
local retry = helpers.retry
local NIL = helpers.NIL
local read_file = require('test.helpers').read_file
@@ -1820,36 +1821,20 @@ describe('LSP', function()
end)
describe('lsp.util.jump_to_location', function()
- local default_target_bufnr
- local default_target_uri = 'file://fake/uri'
-
- local create_buf = function(uri, lines)
- for i, line in ipairs(lines) do
- lines[i] = '"' .. line .. '"'
- end
- lines = table.concat(lines, ", ")
-
- -- Let's set "hidden" to true in order to avoid errors when switching
- -- between buffers in test.
- local code = string.format([[
- vim.api.nvim_set_option('hidden', true)
+ local target_bufnr
- local bufnr = vim.uri_to_bufnr("%s")
- local lines = {%s}
+ before_each(function()
+ target_bufnr = exec_lua [[
+ local bufnr = vim.uri_to_bufnr("file://fake/uri")
+ local lines = {"1st line of text", "å å ɧ 汉语 ↥ 🤦 🦄"}
vim.api.nvim_buf_set_lines(bufnr, 0, 1, false, lines)
return bufnr
- ]], uri, lines)
-
- return exec_lua(code)
- end
-
- before_each(function()
- default_target_bufnr = create_buf(default_target_uri, {'1st line of text', 'å å ɧ 汉语 ↥ 🤦 🦄'})
+ ]]
end)
- local location = function(uri, start_line, start_char, end_line, end_char)
+ local location = function(start_line, start_char, end_line, end_char)
return {
- uri = uri,
+ uri = "file://fake/uri",
range = {
start = { line = start_line, character = start_char },
["end"] = { line = end_line, character = end_char },
@@ -1857,9 +1842,9 @@ describe('LSP', function()
}
end
- local jump = function(bufnr, msg)
+ local jump = function(msg)
eq(true, exec_lua('return vim.lsp.util.jump_to_location(...)', msg))
- eq(bufnr, exec_lua[[return vim.fn.bufnr('%')]])
+ eq(target_bufnr, exec_lua[[return vim.fn.bufnr('%')]])
return {
line = exec_lua[[return vim.fn.line('.')]],
col = exec_lua[[return vim.fn.col('.')]],
@@ -1867,13 +1852,13 @@ describe('LSP', function()
end
it('jumps to a Location', function()
- local pos = jump(default_target_bufnr, location(default_target_uri, 0, 9, 0, 9))
+ local pos = jump(location(0, 9, 0, 9))
eq(1, pos.line)
eq(10, pos.col)
end)
it('jumps to a LocationLink', function()
- local pos = jump(default_target_bufnr, {
+ local pos = jump({
targetUri = "file://fake/uri",
targetSelectionRange = {
start = { line = 0, character = 4 },
@@ -1889,104 +1874,22 @@ describe('LSP', function()
end)
it('jumps to the correct multibyte column', function()
- local pos = jump(default_target_bufnr, location(default_target_uri, 1, 2, 1, 2))
+ local pos = jump(location(1, 2, 1, 2))
eq(2, pos.line)
eq(4, pos.col)
eq('å', exec_lua[[return vim.fn.expand('<cword>')]])
end)
it('adds current position to jumplist before jumping', function()
- exec_lua([[
- vim.api.nvim_win_set_buf(0, ...)
- vim.api.nvim_win_set_cursor(0, {2, 0})
- ]], default_target_bufnr)
- jump(default_target_bufnr, location(default_target_uri, 0, 9, 0, 9))
-
- local mark = exec_lua([[return vim.inspect(vim.api.nvim_buf_get_mark(..., "'"))]], default_target_bufnr)
- eq('{ 2, 0 }', mark)
- end)
-
- it('should not push item to tagstack if destination is the same as source', function()
- -- Set cursor at the 2nd line, 1st character. This is the source position
- -- for the test, and will also be the destination one, making the cursor
- -- "motionless", thus not triggering a push to the tagstack.
- exec_lua(string.format([[
- vim.api.nvim_win_set_buf(0, %d)
- vim.api.nvim_win_set_cursor(0, {2, 0})
- ]], default_target_bufnr))
-
- -- Jump to 'f' in 'foobar', at the 2nd line.
- jump(default_target_bufnr, location(default_target_uri, 1, 0, 1, 0))
+ funcs.nvim_win_set_buf(0, target_bufnr)
+ local mark = funcs.nvim_buf_get_mark(target_bufnr, "'")
+ eq({ 1, 0 }, mark)
- local stack = exec_lua[[return vim.fn.gettagstack()]]
- eq(0, stack.length)
- end)
-
- it('should not push the same item from same buffer twice to tagstack', function()
- -- Set cursor at the 2nd line, 5th character.
- exec_lua(string.format([[
- vim.api.nvim_win_set_buf(0, %d)
- vim.api.nvim_win_set_cursor(0, {2, 4})
- ]], default_target_bufnr))
-
- local stack
-
- -- Jump to 1st line, 1st column.
- jump(default_target_bufnr, location(default_target_uri, 0, 0, 0, 0))
-
- stack = exec_lua[[return vim.fn.gettagstack()]]
- eq({default_target_bufnr, 2, 5, 0}, stack.items[1].from)
-
- -- Go back to 5th character at 2nd line, which is currently at the top of
- -- the tagstack.
- exec_lua(string.format([[
- vim.api.nvim_win_set_cursor(0, {2, 4})
- ]], default_target_bufnr))
-
- -- Jump again to 1st line, 1st column. Since we're jumping from the same
- -- position we have just jumped from, this jump shouldn't be pushed to
- -- the tagstack.
- jump(default_target_bufnr, location(default_target_uri, 0, 0, 0, 0))
+ funcs.nvim_win_set_cursor(0, {2, 3})
+ jump(location(0, 9, 0, 9))
- stack = exec_lua[[return vim.fn.gettagstack()]]
- eq({default_target_bufnr, 2, 5, 0}, stack.items[1].from)
- eq(1, stack.length)
- end)
-
- it('should not push the same item from another buffer twice to tagstack', function()
- local target_uri = 'file://foo/bar'
- local target_bufnr = create_buf(target_uri, {'this is a line', 'foobar'})
-
- -- Set cursor at the 1st line, 3rd character of the default test buffer.
- exec_lua(string.format([[
- vim.api.nvim_win_set_buf(0, %d)
- vim.api.nvim_win_set_cursor(0, {1, 2})
- ]], default_target_bufnr))
-
- local stack
-
- -- Jump to 1st line, 1st column of a different buffer from the source
- -- position.
- jump(target_bufnr, location(target_uri, 0, 0, 0, 0))
-
- stack = exec_lua[[return vim.fn.gettagstack()]]
- eq({default_target_bufnr, 1, 3, 0}, stack.items[1].from)
-
- -- Go back to 3rd character at 1st line of the default test buffer, which
- -- is currently at the top of the tagstack.
- exec_lua(string.format([[
- vim.api.nvim_win_set_buf(0, %d)
- vim.api.nvim_win_set_cursor(0, {1, 2})
- ]], default_target_bufnr))
-
- -- Jump again to 1st line, 1st column of the different buffer. Since
- -- we're jumping from the same position we have just jumped from, this
- -- jump shouldn't be pushed to the tagstack.
- jump(target_bufnr, location(target_uri, 0, 0, 0, 0))
-
- stack = exec_lua[[return vim.fn.gettagstack()]]
- eq({default_target_bufnr, 1, 3, 0}, stack.items[1].from)
- eq(1, stack.length)
+ mark = funcs.nvim_buf_get_mark(target_bufnr, "'")
+ eq({ 2, 3 }, mark)
end)
end)
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua
index f267f9fb5d..d2f9148e8f 100644
--- a/test/functional/treesitter/parser_spec.lua
+++ b/test/functional/treesitter/parser_spec.lua
@@ -235,6 +235,100 @@ void ui_refresh(void)
}, res)
end)
+ it('can match special regex characters like \\ * + ( with `vim-match?`', function()
+ if pending_c_parser(pending) then return end
+
+ insert('char* astring = "\\n"; (1 + 1) * 2 != 2;')
+
+ local res = exec_lua([[
+ cquery = vim.treesitter.parse_query("c", '((_) @plus (vim-match? @plus "^\\\\+$"))'..
+ '((_) @times (vim-match? @times "^\\\\*$"))'..
+ '((_) @paren (vim-match? @paren "^\\\\($"))'..
+ '((_) @escape (vim-match? @escape "^\\\\\\\\n$"))'..
+ '((_) @string (vim-match? @string "^\\"\\\\\\\\n\\"$"))')
+ parser = vim.treesitter.get_parser(0, "c")
+ tree = parser:parse()[1]
+ res = {}
+ for pattern, match in cquery:iter_matches(tree:root(), 0) do
+ -- can't transmit node over RPC. just check the name and range
+ local mrepr = {}
+ for cid,node in pairs(match) do
+ table.insert(mrepr, {cquery.captures[cid], node:type(), node:range()})
+ end
+ table.insert(res, {pattern, mrepr})
+ end
+ return res
+ ]])
+
+ eq({
+ { 2, { { "times", '*', 0, 4, 0, 5 } } },
+ { 5, { { "string", 'string_literal', 0, 16, 0, 20 } } },
+ { 4, { { "escape", 'escape_sequence', 0, 17, 0, 19 } } },
+ { 3, { { "paren", '(', 0, 22, 0, 23 } } },
+ { 1, { { "plus", '+', 0, 25, 0, 26 } } },
+ { 2, { { "times", '*', 0, 30, 0, 31 } } },
+ }, res)
+ end)
+
+ it('supports builtin query predicate any-of?', function()
+ if pending_c_parser(pending) then return end
+
+ insert([[
+ #include <stdio.h>
+
+ int main(void) {
+ int i;
+ for(i=1; i<=100; i++) {
+ if(((i%3)||(i%5))== 0)
+ printf("number= %d FizzBuzz\n", i);
+ else if((i%3)==0)
+ printf("number= %d Fizz\n", i);
+ else if((i%5)==0)
+ printf("number= %d Buzz\n", i);
+ else
+ printf("number= %d\n",i);
+ }
+ return 0;
+ }
+ ]])
+ exec_lua([[
+ function get_query_result(query_text)
+ cquery = vim.treesitter.parse_query("c", query_text)
+ parser = vim.treesitter.get_parser(0, "c")
+ tree = parser:parse()[1]
+ res = {}
+ for cid, node in cquery:iter_captures(tree:root(), 0) do
+ -- can't transmit node over RPC. just check the name, range, and text
+ local text = vim.treesitter.get_node_text(node, 0)
+ local range = {node:range()}
+ table.insert(res, {cquery.captures[cid], node:type(), range, text})
+ end
+ return res
+ end
+ ]])
+
+ local res0 = exec_lua([[return get_query_result(...)]],
+ [[((primitive_type) @c-keyword (#any-of? @c-keyword "int" "float"))]])
+ eq({
+ { "c-keyword", "primitive_type", { 2, 2, 2, 5 }, "int" },
+ { "c-keyword", "primitive_type", { 3, 4, 3, 7 }, "int" },
+ }, res0)
+
+ local res1 = exec_lua([[return get_query_result(...)]],
+ [[
+ ((string_literal) @fizzbuzz-strings (#any-of? @fizzbuzz-strings
+ "\"number= %d FizzBuzz\\n\""
+ "\"number= %d Fizz\\n\""
+ "\"number= %d Buzz\\n\""
+ ))
+ ]])
+ eq({
+ { "fizzbuzz-strings", "string_literal", { 6, 15, 6, 38 }, "\"number= %d FizzBuzz\\n\""},
+ { "fizzbuzz-strings", "string_literal", { 8, 15, 8, 34 }, "\"number= %d Fizz\\n\""},
+ { "fizzbuzz-strings", "string_literal", { 10, 15, 10, 34 }, "\"number= %d Buzz\\n\""},
+ }, res1)
+ end)
+
it('allow loading query with escaped quotes and capture them with `lua-match?` and `vim-match?`', function()
if pending_c_parser(pending) then return end
@@ -308,7 +402,7 @@ void ui_refresh(void)
return list
]]
- eq({ 'contains?', 'eq?', 'is-main?', 'lua-match?', 'match?', 'vim-match?' }, res_list)
+ eq({ 'any-of?', 'contains?', 'eq?', 'is-main?', 'lua-match?', 'match?', 'vim-match?' }, res_list)
end)
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index cd3bea6595..f3b840da21 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -62,6 +62,27 @@ describe('float window', function()
eq(1000, funcs.win_getid())
end)
+ it('win_execute() should work' , function()
+ local buf = meths.create_buf(false, false)
+ meths.buf_set_lines(buf, 0, -1, true, {'the floatwin', 'abc', 'def'})
+ local win = meths.open_win(buf, false, {relative='win', width=16, height=1, row=0, col=10})
+ local line = funcs.win_execute(win, 'echo getline(1)')
+ eq('\nthe floatwin', line)
+ eq('\n1', funcs.win_execute(win, 'echo line(".",'..win.id..')'))
+ eq('\n3', funcs.win_execute(win, 'echo line("$",'..win.id..')'))
+ eq('\n0', funcs.win_execute(win, 'echo line("$", 123456)'))
+ funcs.win_execute(win, 'bwipe!')
+ end)
+
+ it('win_execute() call commands that not allowed' , function()
+ local buf = meths.create_buf(false, false)
+ meths.buf_set_lines(buf, 0, -1, true, {'the floatwin'})
+ local win = meths.open_win(buf, true, {relative='win', width=16, height=1, row=0, col=10})
+ eq(pcall_err(funcs.win_execute, win, 'close'), 'Vim(close):E37: No write since last change (add ! to override)')
+ eq(pcall_err(funcs.win_execute, win, 'bdelete'), 'Vim(bdelete):E89: No write since last change for buffer 2 (add ! to override)')
+ funcs.win_execute(win, 'bwipe!')
+ end)
+
it('closed immediately by autocmd #11383', function()
eq('Error executing lua: [string "<nvim>"]:0: Window was closed immediately',
pcall_err(exec_lua, [[
@@ -1059,8 +1080,8 @@ describe('float window', function()
{1: abb }|
{13: acc }|
]], float_pos={
- [5] = { { id = 1002 }, "NW", 1, 0, 5, true },
- [6] = { { id = -1 }, "NW", 5, 4, 0, false }
+ [5] = { { id = 1002 }, "NW", 1, 0, 5, true, 50 },
+ [6] = { { id = -1 }, "NW", 5, 4, 0, false, 100 }
}, win_viewport={
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0};
[5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 3};
@@ -2737,8 +2758,8 @@ describe('float window', function()
{1: word }|
{1: longtext }|
]], float_pos={
- [4] = {{ id = 1001 }, "NW", 1, 2, 5, true},
- [5] = {{ id = -1 }, "NW", 4, 1, 1, false}
+ [4] = {{ id = 1001 }, "NW", 1, 2, 5, true, 50},
+ [5] = {{ id = -1 }, "NW", 4, 1, 1, false, 100}
}}
else
screen:expect([[
@@ -2824,8 +2845,8 @@ describe('float window', function()
{1:yy }|
{1:zz }|
]], float_pos={
- [4] = {{ id = 1001 }, "NW", 1, 2, 5, true},
- [5] = {{ id = -1 }, "NW", 2, 1, 0, false}
+ [4] = {{ id = 1001 }, "NW", 1, 2, 5, true, 50},
+ [5] = {{ id = -1 }, "NW", 2, 1, 0, false, 100}
}}
else
screen:expect([[
@@ -3086,7 +3107,7 @@ describe('float window', function()
{1:word }|
{1:longtext }|
]], float_pos={
- [4] = {{id = -1}, "NW", 2, 1, 0, false}}
+ [4] = {{id = -1}, "NW", 2, 1, 0, false, 100}}
}
else
screen:expect([[
@@ -3130,8 +3151,8 @@ describe('float window', function()
{15:some info }|
{15:about item }|
]], float_pos={
- [4] = {{id = -1}, "NW", 2, 1, 0, false},
- [6] = {{id = 1002}, "NW", 2, 1, 12, true},
+ [4] = {{id = -1}, "NW", 2, 1, 0, false, 100},
+ [6] = {{id = 1002}, "NW", 2, 1, 12, true, 50},
}}
else
screen:expect([[
@@ -3245,7 +3266,7 @@ describe('float window', function()
{1:word }|
{1:longtext }|
]], float_pos={
- [4] = {{id = -1}, "NW", 2, 1, 0, false},
+ [4] = {{id = -1}, "NW", 2, 1, 0, false, 100},
}}
else
screen:expect([[
@@ -6278,6 +6299,69 @@ describe('float window', function()
]]}
end
end)
+
+ it('can use z-index', function()
+ local buf = meths.create_buf(false,false)
+ local win1 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=1, col=5, zindex=30})
+ meths.win_set_option(win1, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg")
+ local win2 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=6, zindex=50})
+ meths.win_set_option(win2, "winhl", "Normal:Search,EndOfBuffer:Search")
+ local win3 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=3, col=7, zindex=40})
+ meths.win_set_option(win3, "winhl", "Normal:Question,EndOfBuffer:Question")
+
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [3:----------------------------------------]|
+ ## grid 2
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ## grid 3
+ |
+ ## grid 4
+ {7: }|
+ {7:~ }|
+ {7:~ }|
+ ## grid 5
+ {17: }|
+ {17:~ }|
+ {17:~ }|
+ ## grid 6
+ {8: }|
+ {8:~ }|
+ {8:~ }|
+ ]], float_pos={
+ [4] = {{id = 1001}, "NW", 1, 1, 5, true, 30};
+ [5] = {{id = 1002}, "NW", 1, 2, 6, true, 50};
+ [6] = {{id = 1003}, "NW", 1, 3, 7, true, 40};
+ }, win_viewport={
+ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0};
+ [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0};
+ [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0};
+ [6] = {win = {id = 1003}, topline = 0, botline = 2, curline = 0, curcol = 0};
+ }}
+ else
+ screen:expect{grid=[[
+ ^ |
+ {0:~ }{7: }{0: }|
+ {0:~ }{7:~}{17: }{0: }|
+ {0:~ }{7:~}{17:~ }{8: }{0: }|
+ {0:~ }{17:~ }{8: }{0: }|
+ {0:~ }{8:~ }{0: }|
+ |
+ ]]}
+ end
+ end)
end
describe('with ext_multigrid', function()
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index fcf6926433..f73d051857 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -429,6 +429,15 @@ screen:redraw_debug() to show all intermediate screen states. ]])
extstate.win_viewport = nil
end
+ if expected.float_pos then
+ expected.float_pos = deepcopy(expected.float_pos)
+ for _, v in pairs(expected.float_pos) do
+ if not v.external and v[7] == nil then
+ v[7] = 50
+ end
+ end
+ end
+
-- Convert assertion errors into invalid screen state descriptions.
for _, k in ipairs(concat_tables(ext_keys, {'mode', 'mouse_enabled'})) do
-- Empty states are considered the default and need not be mentioned.
@@ -1287,6 +1296,11 @@ function Screen:get_snapshot(attrs, ignore)
end
local function fmt_ext_state(name, state)
+ local function remove_all_metatables(item, path)
+ if path[#path] ~= inspect.METATABLE then
+ return item
+ end
+ end
if name == "win_viewport" then
local str = "{\n"
for k,v in pairs(state) do
@@ -1295,13 +1309,18 @@ local function fmt_ext_state(name, state)
..", curcol = "..v.curcol.."};\n")
end
return str .. "}"
- else
- -- TODO(bfredl): improve formatting of more states
- local function remove_all_metatables(item, path)
- if path[#path] ~= inspect.METATABLE then
- return item
+ elseif name == "float_pos" then
+ local str = "{\n"
+ for k,v in pairs(state) do
+ str = str.." ["..k.."] = {{id = "..v[1].id.."}"
+ for i = 2, #v do
+ str = str..", "..inspect(v[i])
end
+ str = str .. "};\n"
end
+ return str .. "}"
+ else
+ -- TODO(bfredl): improve formatting of more states
return inspect(state,{process=remove_all_metatables})
end
end