diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2021-11-14 12:55:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-14 12:55:16 +0100 |
commit | ee3a58d42e7fce666eef570db6f2944c29303d98 (patch) | |
tree | 9421bec34f8700525c77f1a931643583b5d6aa7f /runtime/lua/vim/lsp.lua | |
parent | 2ef9d2a663db35c73b93606dbe882ca697072cc3 (diff) | |
download | rneovim-ee3a58d42e7fce666eef570db6f2944c29303d98.tar.gz rneovim-ee3a58d42e7fce666eef570db6f2944c29303d98.tar.bz2 rneovim-ee3a58d42e7fce666eef570db6f2944c29303d98.zip |
fix(lsp): ensure buffers are re-attached on rename (#16266)
If a LSP server sent a workspace edit containing a rename the buffers
file name changed without the server receiving a close notification for
the old buffer and without the client properly re-attaching on the new
file.
This affected `Move` code-actions in nvim-jdtls, but also
`vim.lsp.buf.rename` on a class level.
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r-- | runtime/lua/vim/lsp.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 7fa70af779..0fc0a7a7aa 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -472,7 +472,11 @@ local function text_document_did_open_handler(bufnr, client) -- Next chance we get, we should re-do the diagnostics vim.schedule(function() - vim.lsp.diagnostic.redraw(bufnr, client.id) + -- Protect against a race where the buffer disappears + -- between `did_open_handler` and the scheduled function firing. + if vim.api.nvim_buf_is_valid(bufnr) then + vim.lsp.diagnostic.redraw(bufnr, client.id) + end end) end |