mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 03:15:39 +00:00
fix(vim.ui)!: change open() to return pcall-like values #28502
Problem:
`vim.ui.open` unnecessarily invents a different success/failure
convention. Its return type was changed in 57adf8c6e0, so we might as
well change it to have a more conventional form.
Solution:
Change the signature to use the `pcall` convention of `status, result`.
This commit is contained in:
@@ -654,15 +654,15 @@ M[ms.window_showDocument] = function(_, result, ctx, _)
|
||||
|
||||
if result.external then
|
||||
-- TODO(lvimuser): ask the user for confirmation
|
||||
local cmd, err = vim.ui.open(uri)
|
||||
local ret = cmd and cmd:wait(2000) or nil
|
||||
local ok, cmd_or_err = vim.ui.open(uri)
|
||||
local ret = ok and (cmd_or_err --[[@as vim.SystemObj]]):wait(2000) or nil
|
||||
|
||||
if ret == nil or ret.code ~= 0 then
|
||||
return {
|
||||
success = false,
|
||||
error = {
|
||||
code = protocol.ErrorCodes.UnknownErrorCode,
|
||||
message = ret and ret.stderr or err,
|
||||
message = ret and ret.stderr or cmd_or_err,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user