Evaluate:
(defun jpk/next-error-hook ()
(let ((win (get-buffer-window next-error-last-buffer)))
(when (window-live-p win)
(with-selected-window win ;; breaks with xref
(message "window: %s" win)))))
(add-hook 'next-error-hook #'jpk/next-error-hook)
Run xref-find-references on e.g. add-hook
Run next-error or previous-error at least twice.
Repeating next-error doesn't find the next match after the 2nd
invocation. Running previous-error behaves similarly. I can use a mouse
to click on an any match, but next/previous-error will still only move
between the clicked match and the next. I can only cycle between two
matches.