branch: externals/elpa
commit 6d9660152b6d86931a6b1dd25f81a354b77a5ae8
Author: João Távora <joaotav...@gmail.com>
Commit: João Távora <joaotav...@gmail.com>

    Closes #509: fix sorting of completion items
    
    This fixes a problem pointed out by Yuwei Tian <ibluefo...@gmail.com>.
    
    * eglot.el (eglot-completion-at-point): Fix getting :sortText content
    of the completion item.
---
 eglot.el | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/eglot.el b/eglot.el
index 3e9c964..87fd9c8 100644
--- a/eglot.el
+++ b/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

Reply via email to