xref--collect-matches: Fix the application of syntax-propertize
authorDmitry Gutov <dmitry@gutov.dev>
Thu, 9 May 2024 02:57:07 +0000 (05:57 +0300)
committerDmitry Gutov <dmitry@gutov.dev>
Thu, 9 May 2024 02:57:07 +0000 (05:57 +0300)
* lisp/progmodes/xref.el (xref--collect-matches):
Add syntax-ppss-flush-cache call when needed (bug#53749).

lisp/progmodes/xref.el

index 9fa8383ef1019e070c738406e177965059994f5d..90ed8eb20e98558c2b1cbebe8a421831669b2fe0 100644 (file)
@@ -2100,6 +2100,8 @@ Such as the current syntax table and the applied syntax properties."
   (pcase-let* ((`(,line ,file ,text) hit)
                (file (and file (concat xref--hits-remote-id file)))
                (buf (xref--find-file-buffer file))
+               ;; This is fairly dangerouns, but improves performance
+               ;; for large lists, see https://debbugs.gnu.org/53749#227
                (inhibit-modification-hooks t))
     (if buf
         (with-current-buffer buf
@@ -2131,6 +2133,8 @@ Such as the current syntax table and the applied syntax properties."
           (erase-buffer))
         (insert text)
         (goto-char (point-min))
+        (when syntax-needed
+          (syntax-ppss-flush-cache (point)))
         (xref--collect-matches-1 regexp file line
                                  (point)
                                  (point-max)