diff options
author | Sam McCall <sam.mccall@gmail.com> | 2022-01-04 18:28:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-04 09:28:13 -0800 |
commit | d6f0c9539caca217ec1a63d32a048e43ff383e8f (patch) | |
tree | b77434d3f4e1a7c6501b7edc0560ad1404251715 /runtime/lua/vim/lsp/handlers.lua | |
parent | 3fd454bd4a6ceb1989d15cf2d3d5e11d7a253b2d (diff) | |
download | rneovim-d6f0c9539caca217ec1a63d32a048e43ff383e8f.tar.gz rneovim-d6f0c9539caca217ec1a63d32a048e43ff383e8f.tar.bz2 rneovim-d6f0c9539caca217ec1a63d32a048e43ff383e8f.zip |
fix(lsp): suppress ContentModified errors from UI (#16904)
Fixes https://github.com/neovim/neovim/issues/16900
If clients receive a ContentModified error, it generally should not
show it in the UI for the end-user. Clients can resend the request if
they know how to do so.
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#implementationConsiderations
Diffstat (limited to 'runtime/lua/vim/lsp/handlers.lua')
-rw-r--r-- | runtime/lua/vim/lsp/handlers.lua | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index a1d3b2aa94..a48302cc4b 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -439,14 +439,20 @@ for k, fn in pairs(M) do }) if err then - local client = vim.lsp.get_client_by_id(ctx.client_id) - local client_name = client and client.name or string.format("client_id=%d", ctx.client_id) -- LSP spec: -- interface ResponseError: -- code: integer; -- message: string; -- data?: string | number | boolean | array | object | null; - return err_message(client_name .. ': ' .. tostring(err.code) .. ': ' .. err.message) + + -- Per LSP, don't show ContentModified error to the user. + if err.code ~= protocol.ErrorCodes.ContentModified then + local client = vim.lsp.get_client_by_id(ctx.client_id) + local client_name = client and client.name or string.format("client_id=%d", ctx.client_id) + + err_message(client_name .. ': ' .. tostring(err.code) .. ': ' .. err.message) + end + return end return fn(err, result, ctx, config) |