From e644e7ce0b36dd5e75770f3faa0a84f15e2561e8 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 4 Jul 2023 23:33:23 +0200 Subject: 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. --- test/functional/lua/ui_spec.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'test/functional') diff --git a/test/functional/lua/ui_spec.lua b/test/functional/lua/ui_spec.lua index 0f66aad7b3..d1b64419af 100644 --- a/test/functional/lua/ui_spec.lua +++ b/test/functional/lua/ui_spec.lua @@ -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) -- cgit