[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 1.2 90b3bfd 090/101: Fix #148: complex completions work when chos
From: |
Christian Johansson |
Subject: |
[elpa] 1.2 90b3bfd 090/101: Fix #148: complex completions work when chosen from *completions* |
Date: |
Thu, 29 Apr 2021 15:09:07 -0400 (EDT) |
tag: 1.2
commit 90b3bfd5944174e063be69be5ef3420df46f0471
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Fix #148: complex completions work when chosen from *completions*
* eglot.el (eglot-completion-at-point): Make exit-function work
even if its arguments was stripped of its properties.
---
eglot.el | 60 +++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 35 insertions(+), 25 deletions(-)
diff --git a/eglot.el b/eglot.el
index f7b9c86..512e9a6 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1501,7 +1501,8 @@ is not active."
"EGLOT's `completion-at-point' function."
(let ((bounds (bounds-of-thing-at-point 'symbol))
(server (eglot--current-server-or-lose))
- (completion-capability (eglot--server-capable :completionProvider)))
+ (completion-capability (eglot--server-capable :completionProvider))
+ strings)
(when completion-capability
(list
(or (car bounds) (point))
@@ -1514,19 +1515,21 @@ is not active."
:deferred :textDocument/completion
:cancel-on-input t))
(items (if (vectorp resp) resp (plist-get resp :items))))
- (mapcar
- (jsonrpc-lambda (&rest all &key label insertText insertTextFormat
- &allow-other-keys)
- (let ((completion
- (cond ((and (eql insertTextFormat 2)
- (eglot--snippet-expansion-fn))
- (string-trim-left label))
- (t
- (or insertText (string-trim-left label))))))
- (add-text-properties 0 1 all completion)
- (put-text-property 0 1 'eglot--lsp-completion all completion)
- completion))
- items))))
+ (setq
+ strings
+ (mapcar
+ (jsonrpc-lambda (&rest all &key label insertText insertTextFormat
+ &allow-other-keys)
+ (let ((completion
+ (cond ((and (eql insertTextFormat 2)
+ (eglot--snippet-expansion-fn))
+ (string-trim-left label))
+ (t
+ (or insertText (string-trim-left label))))))
+ (add-text-properties 0 1 all completion)
+ (put-text-property 0 1 'eglot--lsp-completion all completion)
+ completion))
+ items)))))
:annotation-function
(lambda (obj)
(cl-destructuring-bind (&key detail kind insertTextFormat
@@ -1572,17 +1575,24 @@ is not active."
(cl-some #'looking-back
(mapcar #'regexp-quote
(plist-get completion-capability :triggerCharacters)))
- :exit-function (lambda (obj _status)
- (cl-destructuring-bind (&key insertTextFormat
- insertText
- &allow-other-keys)
- (text-properties-at 0 obj)
- (when-let ((fn (and (eql insertTextFormat 2)
- (eglot--snippet-expansion-fn))))
- (delete-region (- (point) (length obj)) (point))
- (funcall fn insertText))
- (eglot--signal-textDocument/didChange)
- (eglot-eldoc-function)))))))
+ :exit-function
+ (lambda (comp _status)
+ (let ((comp (if (get-text-property 0 'eglot--lsp-completion comp)
+ comp
+ ;; When selecting from the *Completions*
+ ;; buffer, `comp' won't have any properties. A
+ ;; lookup should fix that (github#148)
+ (cl-find comp strings :test #'string=))))
+ (cl-destructuring-bind (&key insertTextFormat
+ insertText
+ &allow-other-keys)
+ (text-properties-at 0 comp)
+ (when-let ((fn (and (eql insertTextFormat 2)
+ (eglot--snippet-expansion-fn))))
+ (delete-region (- (point) (length comp)) (point))
+ (funcall fn insertText))
+ (eglot--signal-textDocument/didChange)
+ (eglot-eldoc-function))))))))
(defvar eglot--highlights nil "Overlays for textDocument/documentHighlight.")
- [elpa] 1.2 ce9076d 047/101: Close #82: Correctly delete text before expanding snippet completions, (continued)
- [elpa] 1.2 ce9076d 047/101: Close #82: Correctly delete text before expanding snippet completions, Christian Johansson, 2021/04/29
- [elpa] 1.2 746505f 072/101: Require subr-x at compile time (#139), Christian Johansson, 2021/04/29
- [elpa] 1.2 eec30e3 070/101: Fix misspelling of "outstanding" (#74), Christian Johansson, 2021/04/29
- [elpa] 1.2 ff62057 071/101: Fix #138: accept deprecated field in SymbolInformation, Christian Johansson, 2021/04/29
- [elpa] 1.2 f317a7d 069/101: * eglot-tests.el: Disable eclipse connection tests., Christian Johansson, 2021/04/29
- [elpa] 1.2 ff92d67 073/101: Remove duplicates from imenu, Christian Johansson, 2021/04/29
- [elpa] 1.2 660d9e3 078/101: Slightly robustify test engine, Christian Johansson, 2021/04/29
- [elpa] 1.2 da4cd2a 083/101: Make imenu hierarchical, Christian Johansson, 2021/04/29
- [elpa] 1.2 912d10f 088/101: Fix a bug introduced by previous bugfix, Christian Johansson, 2021/04/29
- [elpa] 1.2 8529b55 089/101: Fix #124: add ability to move to LSP-precise columns, Christian Johansson, 2021/04/29
- [elpa] 1.2 90b3bfd 090/101: Fix #148: complex completions work when chosen from *completions*,
Christian Johansson <=
- [elpa] 1.2 63c2bbc 092/101: Add support for TextEdits in completion, Christian Johansson, 2021/04/29
- [elpa] 1.2 d52738f 095/101: Treat tab characters as 1 column wide in position conversion functions, Christian Johansson, 2021/04/29
- [elpa] 1.2 7e9cc05 098/101: Fix #154: fix potential security issue fontifying LSP doc, Christian Johansson, 2021/04/29
- [elpa] 1.2 2bbf06e 097/101: Add support for R's languageserver (#161), Christian Johansson, 2021/04/29
- [elpa] 1.2 c667d79 093/101: Fix #125: add ability to report LSP-compliant columns, Christian Johansson, 2021/04/29
- [elpa] 1.2 a39a446 020/101: Close #61: Snappier completions that don't hinder typing, Christian Johansson, 2021/04/29
- [elpa] 1.2 2e21c12 084/101: * eglot.el (eglot-client-capabilities): Mention supported SymbolKinds., Christian Johansson, 2021/04/29
- [elpa] 1.2 9cee9eb 086/101: Move constants to top instead of forward-declaring, Christian Johansson, 2021/04/29
- [elpa] 1.2 fc9bbf7 096/101: Fix #160: Properly delete inserted text after completion, Christian Johansson, 2021/04/29
- [elpa] 1.2 b573d42 003/101: Close #44: Don't turn on flymake-mode any more than is needed, Christian Johansson, 2021/04/29