diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2024-05-30 10:46:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-30 10:46:26 +0200 |
commit | 5c33815448e11b514678f39cecc74e68131d4628 (patch) | |
tree | 98375094ca5cf9e5d035db555f08e75dd7c1d822 /runtime/lua/vim/lsp/util.lua | |
parent | b2bad0ac91ddb9b33c3547b6fd4f7278794818d9 (diff) | |
download | rneovim-5c33815448e11b514678f39cecc74e68131d4628.tar.gz rneovim-5c33815448e11b514678f39cecc74e68131d4628.tar.bz2 rneovim-5c33815448e11b514678f39cecc74e68131d4628.zip |
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.
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 0099e82f52..d1f0e97065 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -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 -M._get_line_byte_from_position = get_line_byte_from_position - ---@nodoc -M.buf_versions = {} ---@type table<integer,integer> +---@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 return M |