aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2024-11-15 23:34:42 +0100
committerGitHub <noreply@github.com>2024-11-15 14:34:42 -0800
commit6e4df18b457e9743c34068fd6e0a89fd04d3526c (patch)
tree27b360b356b7bc779b06d28c7a0bd27d359c0c3b /test/functional/lua
parentf1748b78e3165a0821a11f5ae1fb9398aa67c535 (diff)
downloadrneovim-6e4df18b457e9743c34068fd6e0a89fd04d3526c.tar.gz
rneovim-6e4df18b457e9743c34068fd6e0a89fd04d3526c.tar.bz2
rneovim-6e4df18b457e9743c34068fd6e0a89fd04d3526c.zip
fix(ui): no fast context for prompt message kinds #31224
Problem: No longer able to show prompt messages with vim.ui_attach(). Solution: Do not execute callback in fast context for prompt message kinds. These events must be safe to show the incoming message so the event itself serves to indicate that the message should be shown immediately.
Diffstat (limited to 'test/functional/lua')
-rw-r--r--test/functional/lua/ui_event_spec.lua22
1 files changed, 20 insertions, 2 deletions
diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua
index f78fced14e..0580442d0a 100644
--- a/test/functional/lua/ui_event_spec.lua
+++ b/test/functional/lua/ui_event_spec.lua
@@ -237,20 +237,21 @@ describe('vim.ui_attach', function()
})
end)
- it('aborts :function on error with ext_messages', function()
+ it('msg_show in fast context', function()
exec_lua([[
vim.ui_attach(ns, { ext_messages = true }, function(event, _, content)
if event == "msg_show" then
- -- "fast-api" does not prevent aborting :function
vim.api.nvim_get_runtime_file("foo", false)
-- non-"fast-api" is not allowed in msg_show callback and should be scheduled
local _, err = pcall(vim.api.nvim_buf_set_lines, 0, -2, -1, false, { content[1][2] })
+ pcall(vim.api.nvim__redraw, { flush = true })
vim.schedule(function()
vim.api.nvim_buf_set_lines(0, -2, -1, false, { content[1][2], err })
end)
end
end)
]])
+ -- "fast-api" does not prevent aborting :function
feed(':func Foo()<cr>bar<cr>endf<cr>:func Foo()<cr>')
screen:expect({
grid = [[
@@ -267,6 +268,23 @@ describe('vim.ui_attach', function()
},
},
})
+ -- No fast context for prompt message kinds
+ feed(':%s/Function/Replacement/c<cr>')
+ screen:expect({
+ grid = [[
+ ^E122: {10:Function} Foo already exists, add !|
+ to replace it |
+ replace with Replacement (y/n/a/q/l/^E/^|
+ Y)? |
+ {1:~ }|
+ ]],
+ messages = {
+ {
+ content = { { 'replace with Replacement (y/n/a/q/l/^E/^Y)?', 6, 19 } },
+ kind = 'confirm_sub',
+ },
+ },
+ })
end)
it('detaches after excessive errors', function()