From: João Távora Date: Fri, 15 Jul 2022 09:25:55 +0000 (+0100) Subject: Tweak some details, fix some bugs X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~35 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9dbc18cbfa5c838453a2036c8d37c673bbc8de1f;p=emacs.git Tweak some details, fix some bugs eglot--recover-workspace-symbol-meta had a bug that still made it choke on improper lists. Also, when simply M-. to the thing at point, let's not lose time on iterating a potentially out-of-date eglot--workspace-symbols-cache. So clear it early in the pre-command-hook. * eglot.el (eglot--workspace-symbols-cache): Move up. (eglot--pre-command-hook): Clear eglot--workspace-symbols-cache here. (eglot--recover-workspace-symbol-meta): Check for consp. GitHub-reference: per https://github.com/joaotavora/eglot/issues/131 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 6d3667a84a9..6f9c4f50f21 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -2101,8 +2101,12 @@ THINGS are either registrations or unregisterations (sic)." :key #'seq-first)))) (eglot-format (point) nil last-input-event)))) +(defvar eglot--workspace-symbols-cache (make-hash-table :test #'equal) + "Cache of `workspace/Symbol' results used by `xref-find-definitions'.") + (defun eglot--pre-command-hook () "Reset some temporary variables." + (clrhash eglot--workspace-symbols-cache) (setq eglot--last-inserted-char nil)) (defun eglot--CompletionParams () @@ -2392,9 +2396,6 @@ Try to visit the target file for a richer summary line." (eglot--current-server-or-lose)) (xref-make-match summary (xref-make-file-location file line column) length))) -(defvar eglot--workspace-symbols-cache (make-hash-table :test #'equal) - "Cache of `workspace/Symbol' results used by `xref-find-definitions'.") - (cl-defmethod xref-backend-identifier-completion-table ((_backend (eql eglot))) (if (eglot--server-capable :workspaceSymbolProvider) (let ((buf (current-buffer))) @@ -2446,10 +2447,10 @@ Try to visit the target file for a richer summary line." "Search `eglot--workspace-symbols-cache' for rich entry of STRING." (catch 'found (maphash (lambda (_k v) - (while v + (while (consp v) ;; Like mess? Ask minibuffer.el about improper lists. (when (equal (car v) string) (throw 'found (car v))) - (setq v (and (consp v) (cdr v))))) + (setq v (cdr v)))) eglot--workspace-symbols-cache))) (add-to-list 'completion-category-overrides