diff options
author | Chris Kipp <ckipp@pm.me> | 2020-04-26 16:51:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-26 16:51:41 +0200 |
commit | 663b83814d3317fd44b59e5a0ac9732494d6e4c9 (patch) | |
tree | fee1ef5b0ed4f9b55e320b2a5f7c2f8f0b0e23d7 /runtime/lua/vim/lsp/util.lua | |
parent | f3ffe0b325170dd214b80e371bee5a56b7054940 (diff) | |
download | rneovim-663b83814d3317fd44b59e5a0ac9732494d6e4c9.tar.gz rneovim-663b83814d3317fd44b59e5a0ac9732494d6e4c9.tar.bz2 rneovim-663b83814d3317fd44b59e5a0ac9732494d6e4c9.zip |
LSP: Add a check for null version in VersionedTextDocumentIdentifier (#12185)
According to the spec there is the possibility that when a
VersionedTextDocumentIdentifier is used in a TextEdit the value may be
null. Currently we don't check for this and always assume that it's set.
So currently if a TextEdit comes in for a rename for example with the
version null, it fails as we are comparing the bufnumber with nil.
https://microsoft.github.io/language-server-protocol/specification#versionedTextDocumentIdentifier
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 49798a452f..be391c8b5b 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -159,7 +159,8 @@ end function M.apply_text_document_edit(text_document_edit) local text_document = text_document_edit.textDocument local bufnr = vim.uri_to_bufnr(text_document.uri) - if M.buf_versions[bufnr] > text_document.version then + -- `VersionedTextDocumentIdentifier`s version may be nil https://microsoft.github.io/language-server-protocol/specification#versionedTextDocumentIdentifier + if text_document.version ~= nil and M.buf_versions[bufnr] > text_document.version then print("Buffer ", text_document.uri, " newer than edits.") return end |