[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/elpa 8dd0a15 67/71: Fix #367: Robustify previous fix of
From: |
João Távora |
Subject: |
[elpa] externals/elpa 8dd0a15 67/71: Fix #367: Robustify previous fix of onChange breakage |
Date: |
Wed, 16 Dec 2020 11:42:28 -0500 (EST) |
branch: externals/elpa
commit 8dd0a159d7103984e4d5f18849a49d49f2444818
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Fix #367: Robustify previous fix of onChange breakage
From the in-code comments:
;; github#259 and github#367: With `capitalize-word' or somesuch,
;; `before-change-functions' always records the whole word's `b-beg'
;; and `b-end'. Similarly, when coalescing two lines into one,
;; `fill-paragraph' they mark the end of the first line up to the end
;; of the second line. In both situations, args received here
;; contradict that information: `beg' and `end' will differ by 1 and
;; will likely only encompass the letter that was capitalized or, in
;; the sentence-joining situation, the replacement of the newline with
;; a space. That's we keep markers _and_ positions so we're able to
;; detect and correct this. We ignore `beg', `len' and
;; `pre-change-len' and send "fuller" information about the region
;; from the markers. I've also experimented with doing this
;; unconditionally but it seems to break when newlines are added.
* eglot.el (eglot--after-change): Robustify fix.
---
eglot.el | 42 ++++++++++++++++++++++++------------------
1 file changed, 24 insertions(+), 18 deletions(-)
diff --git a/eglot.el b/eglot.el
index aa89ae9..3ebdd04 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1729,8 +1729,8 @@ THINGS are either registrations or unregisterations
(sic)."
;; (github#259)
(push `(,(eglot--pos-to-lsp-position beg)
,(eglot--pos-to-lsp-position end)
- (,beg . ,(copy-marker beg))
- (,end . ,(copy-marker end)))
+ (,beg . ,(copy-marker beg nil))
+ (,end . ,(copy-marker end t)))
eglot--recent-changes)))
(defun eglot--after-change (beg end pre-change-length)
@@ -1742,23 +1742,29 @@ Records BEG, END and PRE-CHANGE-LENGTH locally."
(`(,lsp-beg ,lsp-end
(,b-beg . ,b-beg-marker)
(,b-end . ,b-end-marker))
- ;; github#259: With `upcase-word' or somesuch,
+ ;; github#259 and github#367: With `capitalize-word' or somesuch,
;; `before-change-functions' always records the whole word's
- ;; `beg' and `end'. Not only is this longer than needed but
- ;; conflicts with the args received here, which encompass just
- ;; the parts of the word that changed (if any). We detect this
- ;; using markers recorded earlier and at looking
- ;; `pre-change-len'. We also ensure that the before bounds
- ;; indeed belong to the same line (if we don't, we get could get
- ;; #367).
- (when (and (= b-end b-end-marker) (= b-beg b-beg-marker)
- (not (zerop pre-change-length))
- (= (plist-get lsp-beg :line) (plist-get lsp-end :line)))
- (setq lsp-end (eglot--pos-to-lsp-position end)
- lsp-beg (eglot--pos-to-lsp-position beg)))
- (setcar eglot--recent-changes
- `(,lsp-beg ,lsp-end ,pre-change-length
- ,(buffer-substring-no-properties beg end))))
+ ;; `b-beg' and `b-end'. Similarly, when coalescing two lines
+ ;; into one, `fill-paragraph' they mark the end of the first line
+ ;; up to the end of the second line. In both situations, args
+ ;; received here contradict that information: `beg' and `end'
+ ;; will differ by 1 and will likely only encompass the letter
+ ;; that was capitalized or, in the sentence-joining situation,
+ ;; the replacement of the newline with a space. That's we keep
+ ;; markers _and_ positions so we're able to detect and correct
+ ;; this. We ignore `beg', `len' and `pre-change-len' and send
+ ;; "fuller" information about the region from the markers. I've
+ ;; also experimented with doing this unconditionally but it seems
+ ;; to break when newlines are added.
+ (if (and (= b-end b-end-marker) (= b-beg b-beg-marker)
+ (or (/= beg b-beg) (/= end b-end)))
+ (setcar eglot--recent-changes
+ `(,lsp-beg ,lsp-end ,(- b-end-marker b-beg-marker)
+ ,(buffer-substring-no-properties b-beg-marker
+ b-end-marker)))
+ (setcar eglot--recent-changes
+ `(,lsp-beg ,lsp-end ,pre-change-length
+ ,(buffer-substring-no-properties beg end)))))
(_ (setf eglot--recent-changes :emacs-messup)))
(when eglot--change-idle-timer (cancel-timer eglot--change-idle-timer))
(let ((buf (current-buffer)))
- [elpa] externals/elpa ac9239b 46/71: Fix small problems around Eglot's help buffer, (continued)
- [elpa] externals/elpa ac9239b 46/71: Fix small problems around Eglot's help buffer, João Távora, 2020/12/16
- [elpa] externals/elpa 433779d 49/71: * eglot.el (Package-Requires): Require Flymake 1.0.9 and eldoc 1.2.0, João Távora, 2020/12/16
- [elpa] externals/elpa e3ce64a 54/71: Fix #510: use a hash-table for storing resolved completions, João Távora, 2020/12/16
- [elpa] externals/elpa e5fefc7 56/71: Really unbreak eldoc-related tests, João Távora, 2020/12/16
- [elpa] externals/elpa 2172641 65/71: Fix #558: Don't force eglot-strict-mode completely in eglot--dcase, João Távora, 2020/12/16
- [elpa] externals/elpa f9a11fe 63/71: Per #300: Don't send JSON null (Elisp nil) down the wire, João Távora, 2020/12/16
- [elpa] externals/elpa b19b294 64/71: Close #558: handle LSP 3.15's isPreferred code action property, João Távora, 2020/12/16
- [elpa] externals/elpa c34e2f6 50/71: Really install latest dependencies, João Távora, 2020/12/16
- [elpa] externals/elpa 5a2cde9 59/71: Close #511: add built-int support for Godot Engine, João Távora, 2020/12/16
- [elpa] externals/elpa 38971d3 66/71: Fix #367: don't let M-x fill-paragraph break didChange, João Távora, 2020/12/16
- [elpa] externals/elpa 8dd0a15 67/71: Fix #367: Robustify previous fix of onChange breakage,
João Távora <=
- [elpa] externals/elpa a2fa9ab 21/71: Per #408: fontify markdown source code blocks by default, João Távora, 2020/12/16
- [elpa] externals/elpa c9230e8 20/71: Close #408: Declare markdown support iff gfm-view-mode installed, João Távora, 2020/12/16
- [elpa] externals/elpa 3483a2f 10/71: Tests: print contents of *EGLOT ...* buffers in batch mode., João Távora, 2020/12/16
- [elpa] externals/elpa e1e7362 07/71: Fix #445: don't reupdate help buffer if already rendered, João Távora, 2020/12/16
- [elpa] externals/elpa f7a7e33 15/71: Tweak docstring of eglot-server-programs, João Távora, 2020/12/16
- [elpa] externals/elpa eb29f7c 19/71: Close #450: always string-trim markup, João Távora, 2020/12/16
- [elpa] externals/elpa da04fdc 14/71: Close #303: support hierarchical DocumentSymbol in eglot-imenu, João Távora, 2020/12/16
- [elpa] externals/elpa 50f9a69 25/71: Fix #433: survive hover responses with empty markdown strings, João Távora, 2020/12/16
- [elpa] externals/elpa d244cc5 22/71: Per #443: tweak handling of eldoc-echo-area-use-multiline-p, João Távora, 2020/12/16
- [elpa] externals/elpa e690e8c 32/71: Per #474, #478: add more tests for `eglot--guess-contact', João Távora, 2020/12/16