aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/vim_spec.lua38
-rw-r--r--test/functional/legacy/011_autocommands_spec.lua2
-rw-r--r--test/functional/legacy/delete_spec.lua78
-rw-r--r--test/functional/legacy/packadd_spec.lua1
-rw-r--r--test/functional/lua/buffer_updates_spec.lua22
-rw-r--r--test/functional/plugin/health_spec.lua2
-rw-r--r--test/functional/plugin/lsp_spec.lua136
-rw-r--r--test/functional/treesitter/parser_spec.lua50
-rw-r--r--test/functional/ui/decorations_spec.lua131
-rw-r--r--test/functional/ui/float_spec.lua279
10 files changed, 643 insertions, 96 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 3db44f3f11..6926022ee3 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -193,6 +193,44 @@ describe('API', function()
eq('', nvim('exec', 'echo', true))
eq('foo 42', nvim('exec', 'echo "foo" 42', true))
end)
+
+ it('displays messages when output=false', function()
+ local screen = Screen.new(40, 8)
+ screen:attach()
+ screen:set_default_attr_ids({
+ [0] = {bold=true, foreground=Screen.colors.Blue},
+ })
+ meths.exec("echo 'hello'", false)
+ screen:expect{grid=[[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ hello |
+ ]]}
+ end)
+
+ it('does\'t display messages when output=true', function()
+ local screen = Screen.new(40, 8)
+ screen:attach()
+ screen:set_default_attr_ids({
+ [0] = {bold=true, foreground=Screen.colors.Blue},
+ })
+ meths.exec("echo 'hello'", true)
+ screen:expect{grid=[[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]]}
+ end)
end)
describe('nvim_command', function()
diff --git a/test/functional/legacy/011_autocommands_spec.lua b/test/functional/legacy/011_autocommands_spec.lua
index 7cc31dc787..c9c004eec1 100644
--- a/test/functional/legacy/011_autocommands_spec.lua
+++ b/test/functional/legacy/011_autocommands_spec.lua
@@ -70,7 +70,7 @@ describe('file reading, writing and bufnew and filter autocommands', function()
feed_command('let $GZIP = ""')
--execute('au FileChangedShell * echo "caught FileChangedShell"')
feed_command('set bin')
- feed_command("au FileReadPost *.gz '[,']!gzip -d")
+ feed_command("au FileReadPost *.gz '[,']!GZIP= gzip -d")
-- Read and decompress the testfile.
feed_command('$r Xtestfile.gz')
expect('\n'..text1)
diff --git a/test/functional/legacy/delete_spec.lua b/test/functional/legacy/delete_spec.lua
index f2ced8942d..3d2c4a7d91 100644
--- a/test/functional/legacy/delete_spec.lua
+++ b/test/functional/legacy/delete_spec.lua
@@ -17,33 +17,6 @@ describe('Test for delete()', function()
eq(-1, eval("delete('Xfile')"))
end)
- it('directory delete', function()
- command("call mkdir('Xdir1')")
- eq(1, eval("isdirectory('Xdir1')"))
- eq(0, eval("delete('Xdir1', 'd')"))
- eq(0, eval("isdirectory('Xdir1')"))
- eq(-1, eval("delete('Xdir1', 'd')"))
- end)
- it('recursive delete', function()
- command("call mkdir('Xdir1')")
- command("call mkdir('Xdir1/subdir')")
- command("call mkdir('Xdir1/empty')")
- command('split Xdir1/Xfile')
- command("call setline(1, ['a', 'b'])")
- command('w')
- command('w Xdir1/subdir/Xfile')
- command('close')
-
- eq(1, eval("isdirectory('Xdir1')"))
- eq(eval("['a', 'b']"), eval("readfile('Xdir1/Xfile')"))
- eq(1, eval("isdirectory('Xdir1/subdir')"))
- eq(eval("['a', 'b']"), eval("readfile('Xdir1/subdir/Xfile')"))
- eq(1, eval("isdirectory('Xdir1/empty')"))
- eq(0, eval("delete('Xdir1', 'rf')"))
- eq(0, eval("isdirectory('Xdir1')"))
- eq(-1, eval("delete('Xdir1', 'd')"))
- end)
-
it('symlink delete', function()
source([[
split Xfile
@@ -63,55 +36,4 @@ describe('Test for delete()', function()
eq(-1, eval("delete('Xlink')"))
eq(0, eval("delete('Xfile')"))
end)
-
- it('symlink directory delete', function()
- command("call mkdir('Xdir1')")
- if helpers.iswin() then
- command("silent !mklink /j Xlink Xdir1")
- else
- command("silent !ln -s Xdir1 Xlink")
- end
- eq(1, eval("isdirectory('Xdir1')"))
- eq(1, eval("isdirectory('Xlink')"))
- -- Delete the link, not the directory
- eq(0, eval("delete('Xlink')"))
- eq(-1, eval("delete('Xlink')"))
- eq(0, eval("delete('Xdir1', 'd')"))
- end)
-
- it('symlink recursive delete', function()
- source([[
- call mkdir('Xdir3')
- call mkdir('Xdir3/subdir')
- call mkdir('Xdir4')
- split Xdir3/Xfile
- call setline(1, ['a', 'b'])
- w
- w Xdir3/subdir/Xfile
- w Xdir4/Xfile
- close
- if has('win32')
- silent !mklink /j Xdir3\Xlink Xdir4
- else
- silent !ln -s ../Xdir4 Xdir3/Xlink
- endif
- ]])
-
- eq(1, eval("isdirectory('Xdir3')"))
- eq(eval("['a', 'b']"), eval("readfile('Xdir3/Xfile')"))
- eq(1, eval("isdirectory('Xdir3/subdir')"))
- eq(eval("['a', 'b']"), eval("readfile('Xdir3/subdir/Xfile')"))
- eq(1, eval("isdirectory('Xdir4')"))
- eq(1, eval("isdirectory('Xdir3/Xlink')"))
- eq(eval("['a', 'b']"), eval("readfile('Xdir4/Xfile')"))
-
- eq(0, eval("delete('Xdir3', 'rf')"))
- eq(0, eval("isdirectory('Xdir3')"))
- eq(-1, eval("delete('Xdir3', 'd')"))
- -- symlink is deleted, not the directory it points to
- eq(1, eval("isdirectory('Xdir4')"))
- eq(eval("['a', 'b']"), eval("readfile('Xdir4/Xfile')"))
- eq(0, eval("delete('Xdir4/Xfile')"))
- eq(0, eval("delete('Xdir4', 'd')"))
- end)
end)
diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua
index 486a1fe471..d92409059e 100644
--- a/test/functional/legacy/packadd_spec.lua
+++ b/test/functional/legacy/packadd_spec.lua
@@ -20,6 +20,7 @@ describe('packadd', function()
func SetUp()
let s:topdir = expand(getcwd() . '/Xdir')
+ call delete(s:topdir, 'rf')
exe 'set packpath=' . s:topdir
let s:plugdir = expand(s:topdir . '/pack/mine/opt/mytest')
endfunc
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 5da8452a51..d4c65eae5b 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -936,6 +936,28 @@ 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)
+
teardown(function()
os.remove "Xtest-reload"
os.remove "Xtest-undofile"
diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua
index a78ed07876..85c67be8f9 100644
--- a/test/functional/plugin/health_spec.lua
+++ b/test/functional/plugin/health_spec.lua
@@ -118,7 +118,7 @@ describe('health.vim', function()
Error = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
Heading = { bold=true, foreground=Screen.colors.Magenta },
Heading2 = { foreground = Screen.colors.SlateBlue },
- Bar = { foreground=Screen.colors.Purple },
+ Bar = { foreground = 0x6a0dad },
Bullet = { bold=true, foreground=Screen.colors.Brown },
})
command("checkhealth foo success1")
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 557f8a206f..2b7198bf63 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -1820,20 +1820,36 @@ describe('LSP', function()
end)
describe('lsp.util.jump_to_location', function()
- local target_bufnr
+ local default_target_bufnr
+ local default_target_uri = 'file://fake/uri'
- before_each(function()
- target_bufnr = exec_lua [[
- local bufnr = vim.uri_to_bufnr("file://fake/uri")
- local lines = {"1st line of text", "å å ɧ 汉语 ↥ 🤦 🦄"}
+ 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 bufnr = vim.uri_to_bufnr("%s")
+ local lines = {%s}
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(start_line, start_char, end_line, end_char)
+ local location = function(uri, start_line, start_char, end_line, end_char)
return {
- uri = "file://fake/uri",
+ uri = uri,
range = {
start = { line = start_line, character = start_char },
["end"] = { line = end_line, character = end_char },
@@ -1841,9 +1857,9 @@ describe('LSP', function()
}
end
- local jump = function(msg)
+ local jump = function(bufnr, msg)
eq(true, exec_lua('return vim.lsp.util.jump_to_location(...)', msg))
- eq(target_bufnr, exec_lua[[return vim.fn.bufnr('%')]])
+ eq(bufnr, exec_lua[[return vim.fn.bufnr('%')]])
return {
line = exec_lua[[return vim.fn.line('.')]],
col = exec_lua[[return vim.fn.col('.')]],
@@ -1851,13 +1867,13 @@ describe('LSP', function()
end
it('jumps to a Location', function()
- local pos = jump(location(0, 9, 0, 9))
+ local pos = jump(default_target_bufnr, location(default_target_uri, 0, 9, 0, 9))
eq(1, pos.line)
eq(10, pos.col)
end)
it('jumps to a LocationLink', function()
- local pos = jump({
+ local pos = jump(default_target_bufnr, {
targetUri = "file://fake/uri",
targetSelectionRange = {
start = { line = 0, character = 4 },
@@ -1873,11 +1889,105 @@ describe('LSP', function()
end)
it('jumps to the correct multibyte column', function()
- local pos = jump(location(1, 2, 1, 2))
+ local pos = jump(default_target_bufnr, location(default_target_uri, 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))
+
+ 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))
+
+ 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)
+ end)
end)
describe('lsp.util._make_floating_popup_size', function()
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua
index 72ff6f2fb6..f267f9fb5d 100644
--- a/test/functional/treesitter/parser_spec.lua
+++ b/test/functional/treesitter/parser_spec.lua
@@ -599,6 +599,56 @@ int x = INT_MAX;
eq(result, "value")
end)
+
+ describe("when setting a key on a capture", function()
+ it("it should create the nested table", function()
+ insert([[
+ int x = 3;
+ ]])
+
+ local result = exec_lua([[
+ local query = require("vim.treesitter.query")
+ local value
+
+ query = vim.treesitter.parse_query("c", '((number_literal) @number (#set! @number "key" "value"))')
+ parser = vim.treesitter.get_parser(0, "c")
+
+ for pattern, match, metadata in query:iter_matches(parser:parse()[1]:root(), 0) do
+ for _, nested_tbl in pairs(metadata) do
+ return nested_tbl.key
+ end
+ end
+ ]])
+
+ eq(result, "value")
+ end)
+
+ it("it should not overwrite the nested table", function()
+ insert([[
+ int x = 3;
+ ]])
+
+ local result = exec_lua([[
+ local query = require("vim.treesitter.query")
+ local result
+
+ query = vim.treesitter.parse_query("c", '((number_literal) @number (#set! @number "key" "value") (#set! @number "key2" "value2"))')
+ parser = vim.treesitter.get_parser(0, "c")
+
+ for pattern, match, metadata in query:iter_matches(parser:parse()[1]:root(), 0) do
+ for _, nested_tbl in pairs(metadata) do
+ return nested_tbl
+ end
+ end
+ ]])
+ local expected = {
+ ["key"] = "value",
+ ["key2"] = "value2",
+ }
+
+ eq(expected, result)
+ end)
+ end)
end)
end)
end)
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 82d3075be2..98aafd8757 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -66,6 +66,18 @@ describe('decorations providers', function()
expect_events(expected, actual, "beam trace")
end
+ it('does not OOM when inserting, rather than appending, to the decoration provider vector', function()
+ -- Add a dummy decoration provider with a larger ns id than what setup_provider() creates.
+ -- This forces get_decor_provider() to insert into the providers vector,
+ -- 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, {})
+ ]])
+ helpers.assert_alive()
+ end)
+
it('leave a trace', function()
insert(mulholland)
@@ -333,6 +345,35 @@ describe('decorations providers', function()
]]}
end)
+ 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"
+ function on_do(event, ...)
+ if event == "line" then
+ local win, buf, line = ...
+ a.nvim_buf_set_extmark(buf, test_ns, line, 0, {
+ virt_text = {{'+'}, {string.rep(' ', line+1), 'ErrorMsg'}};
+ virt_text_pos='right_align';
+ ephemeral = true;
+ })
+ end
+ end
+ ]]
+
+ screen:expect{grid=[[
+ // just to see if there was an acciden+{2: }|
+ // on Mulholland Drive +{2: }|
+ try_start(); +{2: }|
+ bufref_T save_buf; +{2: }|
+ switch_buffer(&save_buf, buf); +{2: }|
+ posp = getmark(mark, false); +{2: }|
+ restore_buffer(&save_buf);^ +{2: }|
+ |
+ ]]}
+ end)
+
it('can highlight beyond EOL', function()
insert(mulholland)
setup_provider [[
@@ -366,7 +407,7 @@ describe('decorations providers', function()
end)
describe('extmark decorations', function()
- local screen
+ local screen, ns
before_each( function()
clear()
screen = Screen.new(50, 15)
@@ -397,6 +438,8 @@ describe('extmark decorations', function()
[23] = {foreground = Screen.colors.Magenta1, background = Screen.colors.LightGrey};
[24] = {bold = true};
}
+
+ ns = meths.create_namespace 'test'
end)
local example_text = [[
@@ -417,7 +460,6 @@ end]]
insert(example_text)
feed 'gg'
- local ns = meths.create_namespace 'test'
for i = 1,9 do
meths.buf_set_extmark(0, ns, i, 0, { virt_text={{'|', 'LineNr'}}, virt_text_pos='overlay'})
if i == 3 or (i >= 6 and i <= 9) then
@@ -484,7 +526,6 @@ end]]
it('can have virtual text of overlay position and styling', function()
insert(example_text)
feed 'gg'
- local ns = meths.create_namespace 'test'
command 'set ft=lua'
command 'syntax on'
@@ -572,4 +613,88 @@ end]]
{24:-- VISUAL LINE --} |
]]}
end)
+
+ it('can have virtual text of fixed win_col position', function()
+ insert(example_text)
+ feed 'gg'
+ meths.buf_set_extmark(0, ns, 1, 0, { virt_text={{'Very', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'})
+ meths.buf_set_extmark(0, ns, 2, 10, { virt_text={{'Much', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'})
+ meths.buf_set_extmark(0, ns, 3, 15, { virt_text={{'Error', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'})
+ meths.buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_win_col=4, hl_mode='blend'})
+
+ screen:expect{grid=[[
+ ^for _,item in ipairs(items) do |
+ local text, hl_id_cell, cou{4:Very} unpack(item) |
+ if hl_id_cell ~= nil then {4:Much} |
+ hl_id = hl_id_cell {4:Error} |
+ end |
+ for _ = 1, (count or 1) do |
+ local cell = line[colpos] |
+ {1:-} cell.text = text |
+ cell.hl_id = hl_id |
+ colpos = colpos+1 |
+ end |
+ end |
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+
+ feed '3G12|i<cr><esc>'
+ screen:expect{grid=[[
+ for _,item in ipairs(items) do |
+ local text, hl_id_cell, cou{4:Very} unpack(item) |
+ if hl_i {4:Much} |
+ ^d_cell ~= nil then |
+ hl_id = hl_id_cell {4:Error} |
+ end |
+ for _ = 1, (count or 1) do |
+ local cell = line[colpos] |
+ {1:-} cell.text = text |
+ cell.hl_id = hl_id |
+ colpos = colpos+1 |
+ end |
+ end |
+ {1:~ }|
+ |
+ ]]}
+
+ feed 'u:<cr>'
+ screen:expect{grid=[[
+ for _,item in ipairs(items) do |
+ local text, hl_id_cell, cou{4:Very} unpack(item) |
+ if hl_i^d_cell ~= nil then {4:Much} |
+ hl_id = hl_id_cell {4:Error} |
+ end |
+ for _ = 1, (count or 1) do |
+ local cell = line[colpos] |
+ {1:-} cell.text = text |
+ cell.hl_id = hl_id |
+ colpos = colpos+1 |
+ end |
+ end |
+ {1:~ }|
+ {1:~ }|
+ : |
+ ]]}
+
+ feed '8|i<cr><esc>'
+ screen:expect{grid=[[
+ for _,item in ipairs(items) do |
+ local text, hl_id_cell, cou{4:Very} unpack(item) |
+ if |
+ ^hl_id_cell ~= nil then {4:Much} |
+ hl_id = hl_id_cell {4:Error} |
+ end |
+ for _ = 1, (count or 1) do |
+ local cell = line[colpos] |
+ {1:-} cell.text = text |
+ cell.hl_id = hl_id |
+ colpos = colpos+1 |
+ end |
+ end |
+ {1:~ }|
+ |
+ ]]}
+ end)
end)
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 3e73d8b3de..66aaf0c941 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -62,6 +62,24 @@ 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'})
+ 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)
+ 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, [[
@@ -910,6 +928,57 @@ describe('float window', function()
end
end)
+ it('terminates border on edge of viewport when window extends past viewport', function()
+ local buf = meths.create_buf(false, false)
+ meths.open_win(buf, false, {relative='editor', width=40, height=7, row=0, col=0, border="single"})
+ 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
+ {5:┌────────────────────────────────────────┐}|
+ {5:│}{1: }{5:│}|
+ {5:│}{2:~ }{5:│}|
+ {5:│}{2:~ }{5:│}|
+ {5:│}{2:~ }{5:│}|
+ {5:│}{2:~ }{5:│}|
+ {5:│}{2:~ }{5:│}|
+ {5:│}{2:~ }{5:│}|
+ {5:└────────────────────────────────────────┘}|
+ ]], float_pos={
+ [4] = { { id = 1001 }, "NW", 1, 0, 0, true }
+ }, 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};
+ }}
+ else
+ screen:expect{grid=[[
+ {5:^┌──────────────────────────────────────┐}|
+ {5:│}{1: }{5:│}|
+ {5:│}{2:~ }{5:│}|
+ {5:│}{2:~ }{5:│}|
+ {5:│}{2:~ }{5:│}|
+ {5:└──────────────────────────────────────┘}|
+ |
+ ]]}
+ end
+ end)
+
it('with border show popupmenu', function()
screen:try_resize(40,10)
local buf = meths.create_buf(false, false)
@@ -6017,6 +6086,216 @@ describe('float window', function()
]])
end
end)
+
+ it("correctly orders multiple opened floats (current last)", function()
+ local buf = meths.create_buf(false,false)
+ local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
+ meths.win_set_option(win, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg")
+
+ 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:~ }|
+ ]], float_pos={
+ [4] = { { id = 1001 }, "NW", 1, 2, 5, true };
+ }, 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};
+ }}
+ else
+ screen:expect{grid=[[
+ ^ |
+ {0:~ }|
+ {0:~ }{7: }{0: }|
+ {0:~ }{7:~ }{0: }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]]}
+ end
+
+ exec_lua [[
+ local buf = vim.api.nvim_create_buf(false,false)
+ local win = vim.api.nvim_open_win(buf, false, {relative='editor', width=16, height=2, row=3, col=8})
+ vim.api.nvim_win_set_option(win, "winhl", "EndOfBuffer:Normal")
+ buf = vim.api.nvim_create_buf(false,false)
+ win = vim.api.nvim_open_win(buf, true, {relative='editor', width=12, height=2, row=4, col=10})
+ vim.api.nvim_win_set_option(win, "winhl", "Normal:Search,EndOfBuffer:Search")
+ ]]
+
+ 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:~ }|
+ ## grid 5
+ {1: }|
+ {1:~ }|
+ ## grid 6
+ {17:^ }|
+ {17:~ }|
+ ]], float_pos={
+ [4] = { { id = 1001 }, "NW", 1, 2, 5, true };
+ [5] = { { id = 1002 }, "NW", 1, 3, 8, true };
+ [6] = { { id = 1003 }, "NW", 1, 4, 10, true };
+ }, 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:~ }|
+ {0:~ }{7: }{0: }|
+ {0:~ }{7:~ }{1: }{7: }{0: }|
+ {0:~ }{1:~ }{17:^ }{1: }{0: }|
+ {0:~ }{17:~ }{0: }|
+ |
+ ]]}
+ end
+ end)
+
+ it("correctly orders multiple opened floats (non-current last)", function()
+ local buf = meths.create_buf(false,false)
+ local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
+ meths.win_set_option(win, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg")
+
+ 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:~ }|
+ ]], float_pos={
+ [4] = { { id = 1001 }, "NW", 1, 2, 5, true };
+ }, 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};
+ }}
+ else
+ screen:expect{grid=[[
+ ^ |
+ {0:~ }|
+ {0:~ }{7: }{0: }|
+ {0:~ }{7:~ }{0: }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]]}
+ end
+
+ exec_lua [[
+ local buf = vim.api.nvim_create_buf(false,false)
+ local win = vim.api.nvim_open_win(buf, true, {relative='editor', width=12, height=2, row=4, col=10})
+ vim.api.nvim_win_set_option(win, "winhl", "Normal:Search,EndOfBuffer:Search")
+ buf = vim.api.nvim_create_buf(false,false)
+ win = vim.api.nvim_open_win(buf, false, {relative='editor', width=16, height=2, row=3, col=8})
+ vim.api.nvim_win_set_option(win, "winhl", "EndOfBuffer:Normal")
+ ]]
+
+ 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:~ }|
+ ## grid 5
+ {17:^ }|
+ {17:~ }|
+ ## grid 6
+ {1: }|
+ {1:~ }|
+ ]], float_pos={
+ [4] = { { id = 1001 }, "NW", 1, 2, 5, true };
+ [5] = { { id = 1002 }, "NW", 1, 4, 10, true };
+ [6] = { { id = 1003 }, "NW", 1, 3, 8, true };
+ }, 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:~ }|
+ {0:~ }{7: }{0: }|
+ {0:~ }{7:~ }{1: }{7: }{0: }|
+ {0:~ }{1:~ }{17:^ }{1: }{0: }|
+ {0:~ }{17:~ }{0: }|
+ |
+ ]]}
+ end
+ end)
end
describe('with ext_multigrid', function()