aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/lua/ui_event_spec.lua27
-rw-r--r--test/functional/lua/ui_spec.lua8
-rw-r--r--test/functional/ui/decorations_spec.lua38
-rw-r--r--test/functional/ui/popupmenu_spec.lua11
4 files changed, 69 insertions, 15 deletions
diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua
index 57ffcf7b4e..6481da900e 100644
--- a/test/functional/lua/ui_event_spec.lua
+++ b/test/functional/lua/ui_event_spec.lua
@@ -117,4 +117,31 @@ describe('vim.ui_attach', function()
})
eq(0, helpers.eval('v:shell_error'))
end)
+
+ it('can receive accurate message kinds even if they are history', function()
+ exec_lua([[
+ vim.cmd.echomsg("'message1'")
+ print('message2')
+ vim.ui_attach(ns, { ext_messages = true }, on_event)
+ vim.cmd.echomsg("'message3'")
+ ]])
+ feed(':messages<cr>')
+ feed('<cr>')
+
+ local actual = exec_lua([[
+ return vim.tbl_filter(function (event)
+ return event[1] == "msg_history_show"
+ end, events)
+ ]])
+ eq({
+ {
+ 'msg_history_show',
+ {
+ { 'echomsg', { { 0, 'message1' } } },
+ { '', { { 0, 'message2' } } },
+ { 'echomsg', { { 0, 'message3' } } },
+ },
+ },
+ }, actual, inspect(actual))
+ end)
end)
diff --git a/test/functional/lua/ui_spec.lua b/test/functional/lua/ui_spec.lua
index 8f9d8e0f72..9ee99b4905 100644
--- a/test/functional/lua/ui_spec.lua
+++ b/test/functional/lua/ui_spec.lua
@@ -4,6 +4,7 @@ local exec_lua = helpers.exec_lua
local clear = helpers.clear
local feed = helpers.feed
local eval = helpers.eval
+local poke_eventloop = helpers.poke_eventloop
describe('vim.ui', function()
before_each(function()
@@ -111,13 +112,12 @@ describe('vim.ui', function()
eq('CANCEL', exec_lua('return result'))
end)
- it('does not call on_confirm when interrupted with Ctrl-C #18144', function()
+ it('can return nil when interrupted with Ctrl-C #18144', function()
feed(':lua result = "on_confirm not called"<cr>')
- eq('on_confirm not called', exec_lua('return result'))
feed(':lua vim.ui.input({}, function(input) result = input end)<cr>')
+ poke_eventloop() -- This is needed because Ctrl-C flushes input
feed('Inputted Text<c-c>')
- -- Ctrl-C would make vim.ui.input() throw, so `result = input` won't be executed
- eq('on_confirm not called', exec_lua('return result'))
+ eq(true, exec_lua('return (nil == result)'))
end)
it('can return the identical object when an arbitrary opts.cancelreturn object is given', function()
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 5b62f5b3e1..489c33d8b1 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -176,7 +176,13 @@ describe('decorations providers', function()
beamtrace = {}
local function on_do(kind, ...)
if kind == 'win' or kind == 'spell' then
- a.nvim_buf_set_extmark(0, ns, 0, 0, { end_row = 2, end_col = 23, spell = true, ephemeral = true })
+ a.nvim_buf_set_extmark(0, ns, 0, 0, {
+ end_row = 2,
+ end_col = 23,
+ spell = true,
+ priority = 20,
+ ephemeral = true
+ })
end
table.insert(beamtrace, {kind, ...})
end
@@ -234,6 +240,36 @@ describe('decorations providers', function()
{1:~ }|
|
]]}
+
+ -- spell=false with lower priority doesn't disable spell
+ local ns = meths.create_namespace "spell"
+ local id = helpers.curbufmeths.set_extmark(ns, 0, 0, { priority = 30, end_row = 2, end_col = 23, spell = false })
+
+ screen:expect{grid=[[
+ I am well written text. |
+ i am not capitalized. |
+ I am a ^speling mistakke. |
+ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+
+ -- spell=false with higher priority does disable spell
+ helpers.curbufmeths.set_extmark(ns, 0, 0, { id = id, priority = 10, end_row = 2, end_col = 23, spell = false })
+
+ screen:expect{grid=[[
+ I am well written text. |
+ {15:i} am not capitalized. |
+ I am a {16:^speling} {16:mistakke}. |
+ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+
end)
it('can predefine highlights', function()
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
index e43eef4dfd..7e81d1a577 100644
--- a/test/functional/ui/popupmenu_spec.lua
+++ b/test/functional/ui/popupmenu_spec.lua
@@ -3039,18 +3039,9 @@ describe('builtin popupmenu', function()
eq('bar', meths.get_var('menustr'))
end)
- -- oldtest: Test_popup_command()
+ -- oldtest: Test_popup_command_dump()
it(':popup command', function()
exec([[
- menu Test.Foo Foo
- call assert_fails('popup Test.Foo', 'E336:')
- call assert_fails('popup Test.Foo.X', 'E327:')
- call assert_fails('popup Foo', 'E337:')
- unmenu Test.Foo
- ]])
- eq({}, meths.get_vvar('errors'))
-
- exec([[
func ChangeMenu()
aunmenu PopUp.&Paste
nnoremenu 1.40 PopUp.&Paste :echomsg "pasted"<CR>