From e43399b993a9de8e78a200898589bb712cb76e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sat, 22 Dec 2018 15:23:41 +0000 Subject: [PATCH] Fix #190: sort candidates immediately after fetching them. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The :display-sort-function property in capf functions (vs the 'display-sort-function metadata property) doesn't appear to anything, as pointed out by Felicián Németh. * eglot.el (eglot-completion-at-point): Move location of sort function. --- eglot.el | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/eglot.el b/eglot.el index 43bc0235..28a014f3 100644 --- a/eglot.el +++ b/eglot.el @@ -1834,7 +1834,11 @@ is not active." (add-text-properties 0 1 all completion) (put-text-property 0 1 'eglot--lsp-completion all completion) completion)) - items)))) + (sort items + (lambda (a b) + (string-lessp + (or (plist-get a :sortText) "") + (or (plist-get b :sortText) "")))))))) :annotation-function (lambda (obj) (eglot--dbind ((CompletionItem) detail kind insertTextFormat) @@ -1852,12 +1856,6 @@ is not active." (and (eql insertTextFormat 2) (eglot--snippet-expansion-fn) " (snippet)")))))) - :display-sort-function - (lambda (items) - (sort items (lambda (a b) - (string-lessp - (or (get-text-property 0 :sortText a) "") - (or (get-text-property 0 :sortText b) ""))))) :company-doc-buffer (lambda (obj) (let* ((documentation