diff --git a/runtime/lua/vim/lsp/codelens.lua b/runtime/lua/vim/lsp/codelens.lua index 984df9f7ab..f9047fc9e1 100644 --- a/runtime/lua/vim/lsp/codelens.lua +++ b/runtime/lua/vim/lsp/codelens.lua @@ -278,9 +278,10 @@ function Provider:on_win(toprow, botrow) end end + -- Clear extmarks beyond the bottom of the buffer. if botrow == api.nvim_buf_line_count(self.bufnr) - 1 then for _, state in pairs(self.client_state) do - api.nvim_buf_clear_namespace(self.bufnr, state.namespace, botrow, -1) + api.nvim_buf_clear_namespace(self.bufnr, state.namespace, botrow + 1, -1) end end end diff --git a/test/functional/plugin/lsp/codelens_spec.lua b/test/functional/plugin/lsp/codelens_spec.lua index 530ae6639c..78661de6e7 100644 --- a/test/functional/plugin/lsp/codelens_spec.lua +++ b/test/functional/plugin/lsp/codelens_spec.lua @@ -392,8 +392,26 @@ describe('vim.lsp.codelens', function() } | } | | + {1: ▶︎ Run } | ^ | - {1:~ }|*6 + {1:~ }|*5 + 4 fewer lines | + ]]) + feed('dd') + screen:expect([[ + {1: 1 implementation} | + struct S { | + a: i32, | + b: String, | + } | + | + impl S { | + fn new(a: i32, b: String) -> Self { | + S { a, b } | + } | + } | + ^ | + {1:~ }|*7 4 fewer lines | ]]) end)