From 814da26d35db42576f7085bef953f5fe2352baef Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sat, 11 Jul 2020 00:41:43 +0800 Subject: [PATCH] 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 --- lisp/progmodes/eglot.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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 -- 2.39.2