aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
authorMathias Fussenegger <f.mathias@zignar.net>2021-04-14 21:29:32 +0200
committerMathias Fussenegger <f.mathias@zignar.net>2021-04-14 21:29:32 +0200
commitb67f689e4cb08ac3f33432038ae9aec81383a9f3 (patch)
treee8ee043910c2b08da12940e44602f175b5f1558a /runtime/lua/vim/lsp/util.lua
parentd9c7adc64c291f1a368c1417354332f72bdb66d6 (diff)
downloadrneovim-b67f689e4cb08ac3f33432038ae9aec81383a9f3.tar.gz
rneovim-b67f689e4cb08ac3f33432038ae9aec81383a9f3.tar.bz2
rneovim-b67f689e4cb08ac3f33432038ae9aec81383a9f3.zip
lsp: Accept text document edits with version zero
There were a couple of reports of "Buffer X newer than edits" problems. We first assumed that it is incorrect for a server to send 0 as a version - and stated that they should send a `null` instead, given that in the specification the `textDocument` of a `TextDocumentEdit` is a `OptionalVersionedTextDocumentIdentifier`. But it turns out that this was a change in 3.16, and in 3.15 and earlier versions of the specification it was a `VersionedTextDocumentIdentifier` and language servers didn't have a better option than sending `0` if they don't keep track of the version numbers. So this changes the version check to always accept `0` values. See - https://github.com/neovim/neovim/issues/12970 - https://github.com/neovim/neovim/issues/14256 - https://github.com/haskell/haskell-language-server/pull/1727
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r--runtime/lua/vim/lsp/util.lua2
1 files changed, 2 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 28a669778a..783a35a774 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -470,6 +470,8 @@ function M.apply_text_document_edit(text_document_edit, index)
-- `VersionedTextDocumentIdentifier`s version may be null
-- https://microsoft.github.io/language-server-protocol/specification#versionedTextDocumentIdentifier
if should_check_version and (text_document.version
+ and text_document.version ~= vim.NIL
+ and text_document.version > 0
and M.buf_versions[bufnr]
and M.buf_versions[bufnr] > text_document.version) then
print("Buffer ", text_document.uri, " newer than edits.")