[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot ee7f9c6 43/45: Fix #167: correctly insert TextEdi
From: |
João Távora |
Subject: |
[elpa] externals/eglot ee7f9c6 43/45: Fix #167: correctly insert TextEdit-less snippets |
Date: |
Thu, 22 Nov 2018 19:15:34 -0500 (EST) |
branch: externals/eglot
commit ee7f9c657f1b9f4ecdb5212cc4c50e30be83560a
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Fix #167: correctly insert TextEdit-less snippets
Fixes a slight regression from #160.
* eglot.el (eglot-completion-at-point): When there is plain
`insertText' snippet, delete the full completion text.
---
eglot.el | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/eglot.el b/eglot.el
index f4a02ac..9ff9cdf 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1612,24 +1612,31 @@ is not active."
bounds
&allow-other-keys)
(text-properties-at 0 comp)
- (let ((fn (and (eql insertTextFormat 2)
- (eglot--snippet-expansion-fn))))
- (when (or fn textEdit)
- ;; Undo the completion. If before completion the buffer was
- ;; "foo.b" and now is "foo.bar", `comp' will be "bar". We
- ;; want to delete only "ar" (`comp' minus the symbol whose
- ;; bounds we've calculated before) (github#160).
- (delete-region (+ (- (point) (length comp))
- (if bounds (- (cdr bounds) (car bounds)) 0))
- (point)))
+ (let ((snippet-fn (and (eql insertTextFormat 2)
+ (eglot--snippet-expansion-fn))))
(cond (textEdit
+ ;; Undo the just the completed bit. If before
+ ;; completion the buffer was "foo.b" and now is
+ ;; "foo.bar", `comp' will be "bar". We want to
+ ;; delete only "ar" (`comp' minus the symbol
+ ;; whose bounds we've calculated before)
+ ;; (github#160).
+ (delete-region (+ (- (point) (length comp))
+ (if bounds (- (cdr bounds) (car
bounds)) 0))
+ (point))
(cl-destructuring-bind (&key range newText) textEdit
(pcase-let ((`(,beg . ,end) (eglot--range-region
range)))
(delete-region beg end)
(goto-char beg)
- (funcall (or fn #'insert) newText)))
+ (funcall (or snippet-fn #'insert) newText)))
(eglot--apply-text-edits additionalTextEdits))
- (fn (funcall fn insertText))))
+ (snippet-fn
+ ;; A snippet should be inserted, but using plain
+ ;; `insertText'. This requires us to delete the
+ ;; whole completion, since `insertText' is the full
+ ;; completion's text.
+ (delete-region (- (point) (length comp)) (point))
+ (funcall snippet-fn insertText))))
(eglot--signal-textDocument/didChange)
(eglot-eldoc-function))))))))
- [elpa] externals/eglot fdb1941 36/45: Add support for TextEdits in completion, (continued)
- [elpa] externals/eglot fdb1941 36/45: Add support for TextEdits in completion, João Távora, 2018/11/22
- [elpa] externals/eglot d66f2eb 39/45: Treat tab characters as 1 column wide in position conversion functions, João Távora, 2018/11/22
- [elpa] externals/eglot b731db5 41/45: Add support for R's languageserver (#161), João Távora, 2018/11/22
- [elpa] externals/eglot de1728c 44/45: * eglot.el (eglot-completion-at-point): Less chatter., João Távora, 2018/11/22
- [elpa] externals/eglot fc03d7c 40/45: Fix #160: Properly delete inserted text after completion, João Távora, 2018/11/22
- [elpa] externals/eglot 604c1b0 38/45: Per #144: Format documentation of signature parameters, João Távora, 2018/11/22
- [elpa] externals/eglot 894fe5a 42/45: Fix #154: fix potential security issue fontifying LSP doc, João Távora, 2018/11/22
- [elpa] externals/eglot b9e9cf3 34/45: Fix #148: complex completions work when chosen from *completions*, João Távora, 2018/11/22
- [elpa] externals/eglot 0a18dca 37/45: Fix #125: add ability to report LSP-compliant columns, João Távora, 2018/11/22
- [elpa] externals/eglot f291816 45/45: * eglot.el (Version): Bump to 1.2, João Távora, 2018/11/22
- [elpa] externals/eglot ee7f9c6 43/45: Fix #167: correctly insert TextEdit-less snippets,
João Távora <=