mirror of
https://github.com/neovim/neovim.git
synced 2025-12-07 07:02:46 +00:00
fix(vim.ui.open): return (don't show) error message
Problem: Showing an error via vim.notify() makes it awkward for callers such as lsp/handlers.lua to avoid showing redundant errors. Solution: Return the message instead of showing it. Let the caller decide whether and when to show the message.
This commit is contained in:
@@ -5,6 +5,7 @@ local exec_lua = helpers.exec_lua
|
||||
local clear = helpers.clear
|
||||
local feed = helpers.feed
|
||||
local eval = helpers.eval
|
||||
local is_os = helpers.is_os
|
||||
local poke_eventloop = helpers.poke_eventloop
|
||||
|
||||
describe('vim.ui', function()
|
||||
@@ -133,15 +134,17 @@ describe('vim.ui', function()
|
||||
|
||||
describe('open()', function()
|
||||
it('validation', function()
|
||||
exec_lua[[vim.ui.open('non-existent-file')]]
|
||||
matches('vim.ui.open: command failed %(%d%): { "[^"]+", "non%-existent%-file" }', eval('v:errmsg'))
|
||||
if not is_os('bsd') then
|
||||
matches('vim.ui.open: command failed %(%d%): { "[^"]+", "non%-existent%-file" }',
|
||||
exec_lua[[local _, err = vim.ui.open('non-existent-file') ; return err]])
|
||||
end
|
||||
|
||||
exec_lua[[
|
||||
vim.fn.has = function() return 0 end
|
||||
vim.fn.executable = function() return 0 end
|
||||
]]
|
||||
exec_lua[[vim.ui.open('foo')]]
|
||||
eq('vim.ui.open: no handler found (tried: wslview, xdg-open)', eval('v:errmsg'))
|
||||
eq('vim.ui.open: no handler found (tried: wslview, xdg-open)',
|
||||
exec_lua[[local _, err = vim.ui.open('foo') ; return err]])
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user