lsp: fix bug when documentEdit version=null for unattached buffer (#12272)

This commit is contained in:
landerlo
2020-05-14 04:14:52 +01:00
committed by GitHub
parent 55b62a937c
commit 02155f5c10
2 changed files with 49 additions and 57 deletions

View File

@@ -168,10 +168,12 @@ 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)
-- `VersionedTextDocumentIdentifier`s version may be nil https://microsoft.github.io/language-server-protocol/specification#versionedTextDocumentIdentifier
if text_document.version ~= vim.NIL and M.buf_versions[bufnr] > text_document.version then
print("Buffer ", text_document.uri, " newer than edits.")
return
if text_document.version then
-- `VersionedTextDocumentIdentifier`s version may be null https://microsoft.github.io/language-server-protocol/specification#versionedTextDocumentIdentifier
if text_document.version ~= vim.NIL and M.buf_versions[bufnr] ~= nil and M.buf_versions[bufnr] > text_document.version then
print("Buffer ", text_document.uri, " newer than edits.")
return
end
end
M.apply_text_edits(text_document_edit.edits, bufnr)
end