Eglot: check server capability before sending didSave (bug#61478)

* lisp/progmodes/eglot.el (eglot--signal-textDocument/didSave): check
server capability.

Copyright-paperwork-exempt: Yes
This commit is contained in:
~kby 2023-02-14 23:25:05 +00:00 committed by João Távora
parent a3a1ef7bd5
commit 7678b7e46f

View file

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