backport: fix(lsp): guard linked_editing_range refresh on attach (#40900)

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.

(cherry picked from commit 9180c6e093)
This commit is contained in:
Artem Krinitsyn
2026-07-22 13:43:05 +03:00
committed by GitHub
parent ba2ea67a1f
commit 290f7e69a1

View File

@@ -249,7 +249,9 @@ local function attach_linked_editor(bufnr, client)
local linked_editor = LinkedEditor.active[bufnr] or LinkedEditor.new(bufnr)
linked_editor:attach(client_id)
linked_editor:refresh()
if bufnr == api.nvim_get_current_buf() then
linked_editor:refresh()
end
end
---@param bufnr integer