Merge pull request #11927 from Jesse-Bakker/lsp-buf-version

LSP: Use buffer version instead of changedtick for edits
This commit is contained in:
Björn Linse 2020-03-16 21:57:51 +01:00 committed by GitHub
commit 5a5c2f0290
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -614,6 +614,8 @@ do
if tbl_isempty(all_buffer_active_clients[bufnr] or {}) then
return
end
util.buf_versions[bufnr] = changedtick
-- Lazy initialize these because clients may not even need them.
local incremental_changes = once(function(client)
local size_index = encoding_index[client.offset_encoding]

View File

@ -135,7 +135,7 @@ 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)
-- TODO(ashkan) check this is correct.
if api.nvim_buf_get_changedtick(bufnr) > text_document.version then
if (M.buf_versions[bufnr] or 0) > text_document.version then
print("Buffer ", text_document.uri, " newer than edits.")
return
end
@ -961,5 +961,7 @@ function M.character_offset(buf, row, col)
return str_utfindex(line, col)
end
M.buf_versions = {}
return M
-- vim:sw=2 ts=2 et