[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 82523dc621a 2/2: Fix Eglot progress reporting
From: |
João Távora |
Subject: |
emacs-29 82523dc621a 2/2: Fix Eglot progress reporting |
Date: |
Thu, 23 Mar 2023 06:27:55 -0400 (EDT) |
branch: emacs-29
commit 82523dc621ace104d8f379509a436fcb03c48c26
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Fix Eglot progress reporting
When the server sends an "end" message, Emacs's progress reporters
should also be updated.
* lisp/progmodes/eglot.el (eglot-handle-notification $/progress): Rework.
---
lisp/progmodes/eglot.el | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 76f70ead666..b4116dc4aaf 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -2159,22 +2159,24 @@ COMMAND is a symbol naming the command."
(server (_method (eql $/progress)) &key token value)
"Handle $/progress notification identified by TOKEN from SERVER."
(when eglot-report-progress
- (cl-flet ((fmt (&rest args) (mapconcat #'identity args " ")))
+ (cl-flet ((fmt (&rest args) (mapconcat #'identity args " "))
+ (upd (pcnt msg &optional
+ (pr (gethash token (eglot--progress-reporters
server))))
+ (when pr (progress-reporter-update pr pcnt msg))))
(eglot--dbind ((WorkDoneProgress) kind title percentage message) value
(pcase kind
("begin"
- (let* ((prefix (format (concat "[eglot] %s %s:" (when percentage "
"))
- (eglot-project-nickname server) token))
- (pr (puthash token
- (if percentage
- (make-progress-reporter prefix 0 100 percentage 1 0)
- (make-progress-reporter prefix nil nil nil 1 0))
- (eglot--progress-reporters server))))
- (progress-reporter-update pr percentage (fmt title message))))
- ("report"
- (when-let ((pr (gethash token (eglot--progress-reporters server))))
- (progress-reporter-update pr percentage (fmt title message))))
- ("end" (remhash token (eglot--progress-reporters server))))))))
+ (let ((prefix (format (concat "[eglot] %s %s:" (when percentage "
"))
+ (eglot-project-nickname server) token)))
+ (upd percentage (fmt title message)
+ (puthash token
+ (if percentage
+ (make-progress-reporter prefix 0 100 percentage
1 0)
+ (make-progress-reporter prefix nil nil nil 1 0))
+ (eglot--progress-reporters server)))))
+ ("report" (upd percentage (fmt title message)))
+ ("end" (upd (or percentage 100) (fmt title message))
+ (remhash token (eglot--progress-reporters server))))))))
(cl-defmethod eglot-handle-notification
(_server (_method (eql textDocument/publishDiagnostics)) &key uri diagnostics