refactor(lsp): replace util.buf_versions with changedtick (#28943)

`lsp.util.buf_versions` was already derived from changedtick (`on_lines`
from `buf_attach` synced the version)

As far as I can tell there is no need to keep track of the state in a
separate table.
This commit is contained in:
Mathias Fußenegger
2024-05-30 10:46:26 +02:00
committed by GitHub
parent b2bad0ac91
commit 5c33815448
10 changed files with 52 additions and 57 deletions

View File

@@ -509,8 +509,7 @@ function M.apply_text_document_edit(text_document_edit, index, offset_encoding)
and (
text_document.version
and text_document.version > 0
and M.buf_versions[bufnr]
and M.buf_versions[bufnr] > text_document.version
and vim.b[bufnr].changedtick > text_document.version
)
then
print('Buffer ', text_document.uri, ' newer than edits.')
@@ -2200,9 +2199,16 @@ function M._refresh(method, opts)
end
end
---@nodoc
---@deprecated
---@type table<integer,integer>
M.buf_versions = setmetatable({}, {
__index = function(_, bufnr)
vim.deprecate('vim.lsp.util.buf_versions', 'vim.b.changedtick', '0.13')
return vim.b[bufnr].changedtick
end,
})
M._get_line_byte_from_position = get_line_byte_from_position
---@nodoc
M.buf_versions = {} ---@type table<integer,integer>
return M