[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot fc03d7c 40/45: Fix #160: Properly delete inserted
From: |
João Távora |
Subject: |
[elpa] externals/eglot fc03d7c 40/45: Fix #160: Properly delete inserted text after completion |
Date: |
Thu, 22 Nov 2018 19:15:33 -0500 (EST) |
branch: externals/eglot
commit fc03d7c642739e548d36cb8467ac9a235a3fb1c8
Author: Michał Krzywkowski <address@hidden>
Commit: mkcms <address@hidden>
Fix #160: Properly delete inserted text after completion
* eglot.el (eglot-completion-at-point): In :exit-function, delete only
the region of buffer that was inserted by completion.
---
eglot.el | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/eglot.el b/eglot.el
index d9c1c3a..c65d908 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1543,6 +1543,7 @@ is not active."
(string-trim-left label))
(t
(or insertText (string-trim-left label))))))
+ (setq all (append all `(:bounds ,bounds)))
(add-text-properties 0 1 all completion)
(put-text-property 0 1 'eglot--lsp-completion all completion)
completion))
@@ -1604,13 +1605,19 @@ is not active."
insertText
textEdit
additionalTextEdits
+ 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
- (delete-region (- (point) (length comp)) (point)))
+ ;; 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)))
(cond (textEdit
(cl-destructuring-bind (&key range newText) textEdit
(pcase-let ((`(,beg . ,end) (eglot--range-region
range)))
- [elpa] externals/eglot f2ccb77 25/45: Simplify eglot-code-action. Fix compilation warning, (continued)
- [elpa] externals/eglot f2ccb77 25/45: Simplify eglot-code-action. Fix compilation warning, João Távora, 2018/11/22
- [elpa] externals/eglot 2a410e9 30/45: Move constants to top instead of forward-declaring, João Távora, 2018/11/22
- [elpa] externals/eglot f74a80f 27/45: Make imenu hierarchical, João Távora, 2018/11/22
- [elpa] externals/eglot 118f966 26/45: Fix a bug when response to definitions request is a single location, João Távora, 2018/11/22
- [elpa] externals/eglot 3c180c0 19/45: Rework test macros for hopefully more stable testing, João Távora, 2018/11/22
- [elpa] externals/eglot b31ba80 35/45: Tweak solution to #125 with a hint from Fangrui Song, João Távora, 2018/11/22
- [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 <=
- [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, 2018/11/22