fix(lsp): redraw codelens after request completed #38352

Problem:
When code lens is enabled, `on_attach` is executed, but it does not trigger a redraw. Another event, eg, moving the cursor, is required to trigger a redraw and execute the decoration provider's `on_win`.

Solution:
Trigger a `redraw` after each request is completed.
This commit is contained in:
Yi Ming
2026-03-18 23:02:46 +08:00
committed by GitHub
parent 63642ebf80
commit addd408b39
2 changed files with 9 additions and 1 deletions

View File

@@ -128,6 +128,8 @@ function Provider:handler(err, result, ctx)
state.row_lenses = row_lenses
self.version = ctx.version
api.nvim__redraw({ buf = self.bufnr, valid = true, flush = false })
end
---@package

View File

@@ -178,12 +178,18 @@ describe('vim.lsp.codelens', function()
screen:expect({ grid = grid_with_lenses })
end)
it('clears code lenses when disabled', function()
it('clears/shows code lenses when disabled/enabled', function()
exec_lua(function()
vim.lsp.codelens.enable(false)
end)
screen:expect({ grid = grid_without_lenses })
exec_lua(function()
vim.lsp.codelens.enable(true)
end)
screen:expect({ grid = grid_with_lenses })
end)
it('clears code lenses when sole client detaches', function()