From: João Távora Date: Fri, 10 Jul 2020 16:41:43 +0000 (+0800) Subject: Fix sorting of completion items X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~208 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=814da26d35db42576f7085bef953f5fe2352baef;p=emacs.git Fix sorting of completion items This fixes a problem pointed out by Yuwei Tian . * eglot.el (eglot-completion-at-point): Fix getting :sortText content of the completion item. GitHub-reference: closes https://github.com/joaotavora/eglot/issues/509 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 3e9c9641391..87fd9c89025 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -2053,12 +2053,15 @@ is not active." ;; Commit logs for this function help understand what's going on. (when-let (completion-capability (eglot--server-capable :completionProvider)) (let* ((server (eglot--current-server-or-lose)) - (sort-completions (lambda (completions) - (sort completions - (lambda (a b) - (string-lessp - (or (get-text-property 0 :sortText a) "") - (or (get-text-property 0 :sortText b) "")))))) + (sort-completions + (lambda (completions) + (cl-sort completions + #'string-lessp + :key (lambda (c) + (or (plist-get + (get-text-property 0 'eglot--lsp-item c) + :sortText) + ""))))) (metadata `(metadata . ((display-sort-function . ,sort-completions)))) resp items (cached-proxies :none) (proxies