lsp: remove buffer version on buffer_detach (#12029)

When we save the buffer, the buffer is detached and attached again.
So the client also needs to remove the buffer version once.
This commit is contained in:
Hirokazu Hata
2020-04-25 21:58:35 +09:00
committed by GitHub
parent c9f4cac3c9
commit 78d58eaf61
2 changed files with 3 additions and 2 deletions

View File

@@ -198,6 +198,7 @@ local function text_document_did_open_handler(bufnr, client)
} }
} }
client.notify('textDocument/didOpen', params) client.notify('textDocument/didOpen', params)
util.buf_versions[bufnr] = params.textDocument.version
end end
--- LSP client object. --- LSP client object.
@@ -722,6 +723,7 @@ function lsp.buf_attach_client(bufnr, client_id)
client.notify('textDocument/didClose', params) client.notify('textDocument/didClose', params)
end end
end) end)
util.buf_versions[bufnr] = nil
all_buffer_active_clients[bufnr] = nil all_buffer_active_clients[bufnr] = nil
end; end;
-- TODO if we know all of the potential clients ahead of time, then we -- TODO if we know all of the potential clients ahead of time, then we

View File

@@ -134,8 +134,7 @@ end
function M.apply_text_document_edit(text_document_edit) function M.apply_text_document_edit(text_document_edit)
local text_document = text_document_edit.textDocument local text_document = text_document_edit.textDocument
local bufnr = vim.uri_to_bufnr(text_document.uri) local bufnr = vim.uri_to_bufnr(text_document.uri)
-- TODO(ashkan) check this is correct. if M.buf_versions[bufnr] > text_document.version then
if (M.buf_versions[bufnr] or 0) > text_document.version then
print("Buffer ", text_document.uri, " newer than edits.") print("Buffer ", text_document.uri, " newer than edits.")
return return
end end