aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2025-01-07 14:20:45 +0100
committerLuuk van Baal <luukvbaal@gmail.com>2025-01-09 13:35:40 +0100
commitead5683ff9994c0fbfc6c38e0911d9455777550b (patch)
treeaf8d0e65f3640393077202bbf44a57da7199ac76 /test
parentb67fcd0488746b079a3b721ae4800af94cd126e1 (diff)
downloadrneovim-ead5683ff9994c0fbfc6c38e0911d9455777550b.tar.gz
rneovim-ead5683ff9994c0fbfc6c38e0911d9455777550b.tar.bz2
rneovim-ead5683ff9994c0fbfc6c38e0911d9455777550b.zip
feat(api): add err field to nvim_echo() opts
Problem: We want to deprecate `nvim_err_write(ln)()` but there is no obvious replacement (from Lua). Meanwhile we already have `nvim_echo()` with an `opts` argument. Solution: Add `err` argument to `nvim_echo()` that directly maps to `:echoerr`.
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/vim_spec.lua24
-rw-r--r--test/functional/ui/messages_spec.lua15
2 files changed, 39 insertions, 0 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 578fa361e8..e0ab31f702 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -3680,6 +3680,30 @@ describe('API', function()
async_meths.nvim_echo({ { 'msg\nmsg' }, { 'msg' } }, false, {})
eq('', exec_capture('messages'))
end)
+
+ it('can print error message', function()
+ async_meths.nvim_echo({ { 'Error\nMessage' } }, false, { err = true })
+ screen:expect([[
+ |
+ {1:~ }|*3
+ {3: }|
+ {9:Error} |
+ {9:Message} |
+ {6:Press ENTER or type command to continue}^ |
+ ]])
+ feed(':messages<CR>')
+ screen:expect([[
+ ^ |
+ {1:~ }|*6
+ |
+ ]])
+ async_meths.nvim_echo({ { 'Error' }, { 'Message', 'Special' } }, false, { err = true })
+ screen:expect([[
+ ^ |
+ {1:~ }|*6
+ {9:Error}{16:Message} |
+ ]])
+ end)
end)
describe('nvim_open_term', function()
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index 77ffc475b0..06048c665c 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -315,6 +315,21 @@ describe('ui/ext_messages', function()
})
feed('<Esc>')
command('set showmode')
+
+ -- kind=echoerr for nvim_echo() err
+ feed(':call nvim_echo([["Error"], ["Message", "Special"]], 1, #{ err:1 })<CR>')
+ screen:expect({
+ cmdline = { {
+ abort = false,
+ } },
+ messages = {
+ {
+ content = { { 'Error', 9, 6 }, { 'Message', 16, 99 } },
+ history = true,
+ kind = 'echoerr',
+ },
+ },
+ })
end)
it(':echoerr', function()