From 9180c6e093391969b2751d09b6fa0397dbfc7882 Mon Sep 17 00:00:00 2001 From: Artem Krinitsyn Date: Tue, 21 Jul 2026 20:32:13 +0300 Subject: [PATCH] fix(lsp): guard linked_editing_range refresh on attach (#40888) Problem: on_attach() calls refresh(), but there is no guarantee the attached buffer is the current buffer. This can make linked editing request handling assume the wrong window. Solution: Call refresh() only if the current buffer is attached. This keeps the initial highlighting behavior while avoiding making incorrect request. --- runtime/lua/vim/lsp/linked_editing_range.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/lua/vim/lsp/linked_editing_range.lua b/runtime/lua/vim/lsp/linked_editing_range.lua index 96d5c96646..8d37c074dd 100644 --- a/runtime/lua/vim/lsp/linked_editing_range.lua +++ b/runtime/lua/vim/lsp/linked_editing_range.lua @@ -195,7 +195,9 @@ function LinkedEditor:on_attach(client_id) self.client_state[client_id] = state end - self:refresh() + if self.bufnr == api.nvim_get_current_buf() then + self:refresh() + end end ---@package