mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 12:45:17 -07:00
fix(lsp): defer writing error msgs (#27688)
Context: Nvim catches errors from the user's `on_exit` and rpc handler callbacks and prints the error message. Problem: Printing the error message uses Nvim api functions. But callbacks mentioned above run in `:h lua-loop-callbacks` where most of `vim.api` is not allowed, so Nvim itself raises error. Solution: `vim.schedule()` the error reporting when necessary.
This commit is contained in:
parent
ee4bbc3af2
commit
39cc38a87b
@ -691,8 +691,16 @@ local wait_result_reason = { [-1] = 'timeout', [-2] = 'interrupted', [-3] = 'err
|
||||
---
|
||||
--- @param ... string List to write to the buffer
|
||||
local function err_message(...)
|
||||
api.nvim_err_writeln(table.concat(vim.tbl_flatten({ ... })))
|
||||
api.nvim_command('redraw')
|
||||
local message = table.concat(vim.tbl_flatten({ ... }))
|
||||
if vim.in_fast_event() then
|
||||
vim.schedule(function()
|
||||
api.nvim_err_writeln(message)
|
||||
api.nvim_command('redraw')
|
||||
end)
|
||||
else
|
||||
api.nvim_err_writeln(message)
|
||||
api.nvim_command('redraw')
|
||||
end
|
||||
end
|
||||
|
||||
--- @private
|
||||
|
Loading…
Reference in New Issue
Block a user