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

@@ -116,7 +116,7 @@ local function tokens_to_ranges(data, bufnr, client, request)
if elapsed_ns > yield_interval_ns then
vim.schedule(function()
coroutine.resume(co, util.buf_versions[bufnr])
coroutine.resume(co, vim.b[bufnr].changedtick)
end)
if request.version ~= coroutine.yield() then
-- request became stale since the last time the coroutine ran.
@@ -275,7 +275,7 @@ end
---
---@package
function STHighlighter:send_request()
local version = util.buf_versions[self.bufnr]
local version = vim.b[self.bufnr].changedtick
self:reset_timer()
@@ -418,7 +418,7 @@ end
function STHighlighter:on_win(topline, botline)
for client_id, state in pairs(self.client_state) do
local current_result = state.current_result
if current_result.version and current_result.version == util.buf_versions[self.bufnr] then
if current_result.version and current_result.version == vim.b[self.bufnr].changedtick then
if not current_result.namespace_cleared then
api.nvim_buf_clear_namespace(self.bufnr, state.namespace, 0, -1)
current_result.namespace_cleared = true