[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot d254f97 082/139: Solve another textDocument/didCh
From: |
João Távora |
Subject: |
[elpa] externals/eglot d254f97 082/139: Solve another textDocument/didChange bug |
Date: |
Mon, 14 May 2018 09:54:58 -0400 (EDT) |
branch: externals/eglot
commit d254f974e1991f3787da5c06a76da33ab1181548
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Solve another textDocument/didChange bug
* eglot.el (eglot--signal-textDocument/didChange): Rework a bit.
(eglot--after-change): Store the actual after-text in the
eglot--recent-after-changes.
---
eglot.el | 99 ++++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 56 insertions(+), 43 deletions(-)
diff --git a/eglot.el b/eglot.el
index 045588d..f6bf010 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1128,52 +1128,65 @@ were deleted/added)"
"Hook onto `after-change-functions'.
Records START, END and PRE-CHANGE-LENGTH locally."
(cl-incf eglot--versioned-identifier)
- (push (list start end pre-change-length) eglot--recent-after-changes))
+ (push (list start end pre-change-length
+ (buffer-substring-no-properties start end))
+ eglot--recent-after-changes))
(defun eglot--signal-textDocument/didChange ()
"Send textDocument/didChange to server."
- (when (and eglot--recent-before-changes
- eglot--recent-after-changes)
- (let* ((proc (eglot--current-process-or-lose))
- (sync-kind (plist-get (eglot--capabilities proc)
:textDocumentSync)))
- (save-restriction
- (widen)
- (unless (or (not sync-kind)
- (eq sync-kind 0))
- (eglot--notify
- proc
- :textDocument/didChange
- (eglot--obj
- :textDocument
- (eglot--current-buffer-VersionedTextDocumentIdentifier)
- :contentChanges
- (if (or (eq sync-kind 1)
- (/= (length eglot--recent-before-changes)
- (length eglot--recent-after-changes)))
- (vector
- (eglot--obj
- :text (buffer-substring-no-properties (point-min)
(point-max))))
- (apply
- #'vector
- (mapcar
- (pcase-lambda (`(,before-start-position
- ,before-end-position
- ,after-start
- ,after-end
- ,len))
- (eglot--obj
- :range
- (eglot--obj
- :start before-start-position
- :end before-end-position)
- :rangeLength len
- :text (buffer-substring-no-properties after-start
after-end)))
- (reverse
- (cl-mapcar 'append
- eglot--recent-before-changes
- eglot--recent-after-changes)))))))))))
- (setq eglot--recent-before-changes nil
- eglot--recent-after-changes nil))
+ (unwind-protect
+ (when (or eglot--recent-before-changes
+ eglot--recent-after-changes)
+ (let* ((proc (eglot--current-process-or-lose))
+ (sync-kind (plist-get (eglot--capabilities proc)
+ :textDocumentSync))
+ (emacs-messup
+ (/= (length eglot--recent-before-changes)
+ (length eglot--recent-after-changes)))
+ (full-sync-p (or (eq sync-kind 1) emacs-messup)))
+ (when emacs-messup
+ (unless (eq sync-kind 1)
+ (eglot--warn "Using full sync because before: %s and after: %s"
+ eglot--recent-before-changes
+ eglot--recent-after-changes)))
+ (save-restriction
+ (widen)
+ (unless (or (not sync-kind)
+ (eq sync-kind 0))
+ (eglot--notify
+ proc
+ :textDocument/didChange
+ (eglot--obj
+ :textDocument
+ (eglot--current-buffer-VersionedTextDocumentIdentifier)
+ :contentChanges
+ (if full-sync-p
+ (vector
+ (eglot--obj
+ :text (buffer-substring-no-properties (point-min)
+ (point-max))))
+ (apply
+ #'vector
+ (mapcar
+ (pcase-lambda (`(,before-start-position
+ ,before-end-position
+ ,_after-start
+ ,_after-end
+ ,len
+ ,after-text))
+ (eglot--obj
+ :range
+ (eglot--obj
+ :start before-start-position
+ :end before-end-position)
+ :rangeLength len
+ :text after-text))
+ (reverse
+ (cl-mapcar 'append
+ eglot--recent-before-changes
+ eglot--recent-after-changes)))))))))))
+ (setq eglot--recent-before-changes nil
+ eglot--recent-after-changes nil)))
(defun eglot--signal-textDocument/didOpen ()
"Send textDocument/didOpen to server."
- [elpa] externals/eglot dda11dd 095/139: Try to fix some textDocument/completion bugs, (continued)
- [elpa] externals/eglot dda11dd 095/139: Try to fix some textDocument/completion bugs, João Távora, 2018/05/14
- [elpa] externals/eglot ea918ab 066/139: Include source info in diagnostics, João Távora, 2018/05/14
- [elpa] externals/eglot a199c8e 070/139: Honour textDocumentSync, João Távora, 2018/05/14
- [elpa] externals/eglot e86f9b4 073/139: New helper eglot--sync-request, João Távora, 2018/05/14
- [elpa] externals/eglot 1add335 078/139: Workaround two suspected Emacs bugs, João Távora, 2018/05/14
- [elpa] externals/eglot 889ef20 085/139: Tweak the async request engine., João Távora, 2018/05/14
- [elpa] externals/eglot 193c57d 075/139: Half-decent xref support, João Távora, 2018/05/14
- [elpa] externals/eglot fc6879f 084/139: Explain why didOpen on after-revert-hook is a bad idea, João Távora, 2018/05/14
- [elpa] externals/eglot 24466a9 096/139: When killing server, always wait 3 seconds, João Távora, 2018/05/14
- [elpa] externals/eglot fceb6bb 090/139: Get rid of eglot--special-buffer-process, João Távora, 2018/05/14
- [elpa] externals/eglot d254f97 082/139: Solve another textDocument/didChange bug,
João Távora <=
- [elpa] externals/eglot f257d63 089/139: * eglot.el: Reformat to shave off some lines., João Távora, 2018/05/14
- [elpa] externals/eglot c7bd095 118/139: Improve eglot-eldoc-function, João Távora, 2018/05/14
- [elpa] externals/eglot 3e0f1c3 122/139: Misc little adjustments for readability, João Távora, 2018/05/14
- [elpa] externals/eglot 3dcbc30 109/139: Add minimal headers, commentary and autoloads, João Távora, 2018/05/14
- [elpa] externals/eglot 71e47d2 102/139: Fix odd bugs and tweak stuff, João Távora, 2018/05/14
- [elpa] externals/eglot 05c67ee 112/139: Adjust flymake integration, João Távora, 2018/05/14
- [elpa] externals/eglot 9ff97a6 079/139: Increase request timeout length to 10 seconds, João Távora, 2018/05/14
- [elpa] externals/eglot 571b08f 076/139: Fix the odd bug here and there, João Távora, 2018/05/14
- [elpa] externals/eglot a7ddce6 080/139: Support javascript's javascript-typescript-langserver, João Távora, 2018/05/14
- [elpa] externals/eglot d40f9ac 094/139: Half-decent imenu support via textDocument/documentSymbol, João Távora, 2018/05/14