]> git.eshelyaron.com Git - emacs.git/commitdiff
Eglot: check server capability before sending didSave (bug#61478)
author~kby <kby@tilde.team>
Tue, 14 Feb 2023 23:25:05 +0000 (23:25 +0000)
committerJoão Távora <joaotavora@gmail.com>
Tue, 14 Feb 2023 23:32:36 +0000 (23:32 +0000)
* lisp/progmodes/eglot.el (eglot--signal-textDocument/didSave): check
server capability.

Copyright-paperwork-exempt: Yes

lisp/progmodes/eglot.el

index 58d519548e01a7fc6a021a587a27250fdbca5dc1..82401b685ceea25b5e00c3ac420e4da8fc0b28bf 100644 (file)
@@ -2496,13 +2496,14 @@ When called interactively, use the currently active server"
 (defun eglot--signal-textDocument/didSave ()
   "Send textDocument/didSave to server."
   (eglot--signal-textDocument/didChange)
-  (jsonrpc-notify
-   (eglot--current-server-or-lose)
-   :textDocument/didSave
-   (list
-    ;; TODO: Handle TextDocumentSaveRegistrationOptions to control this.
-    :text (buffer-substring-no-properties (point-min) (point-max))
-    :textDocument (eglot--TextDocumentIdentifier))))
+  (when (eglot--server-capable :textDocumentSync :save)
+    (jsonrpc-notify
+     (eglot--current-server-or-lose)
+     :textDocument/didSave
+     (list
+      ;; TODO: Handle TextDocumentSaveRegistrationOptions to control this.
+      :text (buffer-substring-no-properties (point-min) (point-max))
+      :textDocument (eglot--TextDocumentIdentifier)))))
 
 (defun eglot-flymake-backend (report-fn &rest _more)
   "A Flymake backend for Eglot.