emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/eglot c8e7ab0 16/24: Don't rely on Flymake's idle timer


From: João Távora
Subject: [elpa] externals/eglot c8e7ab0 16/24: Don't rely on Flymake's idle timer for textDocument/didChange
Date: Sat, 26 May 2018 14:31:16 -0400 (EDT)

branch: externals/eglot
commit c8e7ab0c6e1cbd4902fdac6ce0435e84f9790b25
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    Don't rely on Flymake's idle timer for textDocument/didChange
    
    * eglot.el (eglot--after-change): Set idle timer here.
    (eglot--change-idle-timer): New var.
    (eglot--signal-textDocument/didChange): No seed to set spinner here.
    (eglot-flymake-backend) Don't send didChange here.
---
 eglot.el | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/eglot.el b/eglot.el
index 3d36344..8fe24ed 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1131,6 +1131,8 @@ THINGS are either registrations or unregisterations."
   (cl-plusp (+ (length (car eglot--recent-changes))
                (length (cdr eglot--recent-changes)))))
 
+(defvar eglot--change-idle-timer nil "Idle timer for textDocument/didChange.")
+
 (defun eglot--before-change (start end)
   "Hook onto `before-change-functions'.
 Records START and END, crucially convert them into
@@ -1149,7 +1151,12 @@ Records START, END and PRE-CHANGE-LENGTH locally."
   (setf (cdr eglot--recent-changes)
         (vconcat (cdr eglot--recent-changes)
                  `[(,pre-change-length
-                    ,(buffer-substring-no-properties start end))])))
+                    ,(buffer-substring-no-properties start end))]))
+  (when eglot--change-idle-timer (cancel-timer eglot--change-idle-timer))
+  (setq eglot--change-idle-timer
+        (run-with-idle-timer
+         0.5 nil (lambda () (eglot--signal-textDocument/didChange)
+                   (setq eglot--change-idle-timer nil)))))
 
 (defun eglot--signal-textDocument/didChange ()
   "Send textDocument/didChange to server."
@@ -1166,8 +1173,7 @@ Records START, END and PRE-CHANGE-LENGTH locally."
         (eglot--notify
          server :textDocument/didChange
          (eglot--obj
-          :textDocument
-          (eglot--VersionedTextDocumentIdentifier)
+          :textDocument (eglot--VersionedTextDocumentIdentifier)
           :contentChanges
           (if full-sync-p (vector
                            (eglot--obj
@@ -1180,7 +1186,6 @@ Records START, END and PRE-CHANGE-LENGTH locally."
                                             :rangeLength len
                                             :text after-text)])))))
       (setq eglot--recent-changes (cons [] []))
-      (setf (eglot--spinner server) (list nil :textDocument/didChange t))
       (eglot--call-deferred server))))
 
 (defun eglot--signal-textDocument/didOpen ()
@@ -1225,9 +1230,7 @@ Calls REPORT-FN maybe if server publishes diagnostics in 
time."
   ;; Report anything unreported
   (when eglot--unreported-diagnostics
     (funcall report-fn eglot--unreported-diagnostics)
-    (setq eglot--unreported-diagnostics nil))
-  ;; Signal a didChange that might eventually bring new diagnotics
-  (eglot--signal-textDocument/didChange))
+    (setq eglot--unreported-diagnostics nil)))
 
 (defun eglot-xref-backend ()
   "EGLOT xref backend."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]