Update 'xref-num-matches-found' when reverting *xref* buffer
authorEshel Yaron <me@eshelyaron.com>
Mon, 11 Nov 2024 18:45:10 +0000 (19:45 +0100)
committerDmitry Gutov <dmitry@gutov.dev>
Thu, 14 Nov 2024 02:26:54 +0000 (04:26 +0200)
* lisp/progmodes/xref.el (xref--insert-xrefs):
Update 'xref-num-matches-found' here...
(xref--show-xref-buffer): ...instead of here (bug#74313).

lisp/progmodes/xref.el

index 5ecb8664da02dbdfd7cf6c98f3b34bceab3bd217..125616398f02599c88ef6faa1dcb520f63013677 100644 (file)
@@ -1140,6 +1140,7 @@ XREF-ALIST is of the form ((GROUP . (XREF ...)) ...), where
 GROUP is a string for decoration purposes and XREF is an
 `xref-item' object."
   (require 'compile) ; For the compilation faces.
+  (setq xref-num-matches-found 0)
   (cl-loop for (group . xrefs) in xref-alist
            for max-line = (cl-loop for xref in xrefs
                                    maximize (xref-location-line
@@ -1159,6 +1160,7 @@ GROUP is a string for decoration purposes and XREF is an
            (xref--insert-propertized '(face xref-file-header xref-group t)
                                      group "\n")
            (dolist (xref xrefs)
+             (cl-incf xref-num-matches-found)
              (pcase-let (((cl-struct xref-item summary location) xref))
                (let* ((line (xref-location-line location))
                       (prefix
@@ -1248,7 +1250,6 @@ Return an alist of the form ((GROUP . (XREF ...)) ...)."
       (xref--ensure-default-directory dd (current-buffer))
       (xref--xref-buffer-mode)
       (xref--show-common-initialize xref-alist fetcher alist)
-      (setq xref-num-matches-found (length xrefs))
       (setq mode-line-process (list xref-mode-line-matches))
       (pop-to-buffer (current-buffer))
       (setq buf (current-buffer)))