From: João Távora Date: Thu, 21 Jun 2018 16:20:20 +0000 (+0100) Subject: Report progress when applying edits X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~493 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1e49d2f3b45be49278f13a4b9fbb5dab2707952a;p=emacs.git Report progress when applying edits Use make-progress-reporter in eglot--apply-text-edits As suggested by mkcms , but do it in eglot--apply-text-edits, where it benefits all its users. * eglot.el (eglot--apply-text-edits): Use a progress reporter. Fix marker point recovery. GitHub-reference: close https://github.com/joaotavora/eglot/issues/23 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 489e3658b11..9e686eece63 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1584,18 +1584,27 @@ If SKIP-SIGNATURE, don't try to send textDocument/signatureHelp." (eglot--error "Edits on `%s' require version %d, you have %d" (current-buffer) version eglot--versioned-identifier)) (atomic-change-group - (mapc (pcase-lambda (`(,newText ,beg . ,end)) - (save-restriction - (narrow-to-region beg end) + (let* ((howmany (length edits)) + (reporter (make-progress-reporter + (format "[eglot] applying %s edits to `%s'..." + howmany (current-buffer)) + 0 howmany)) + (done 0)) + (mapc (pcase-lambda (`(,newText ,beg . ,end)) (let ((source (current-buffer))) (with-temp-buffer (insert newText) (let ((temp (current-buffer))) - (with-current-buffer source (replace-buffer-contents temp))))))) - (mapcar (eglot--lambda (&key range newText) - (cons newText (eglot--range-region range 'markers))) - edits))) - (eglot--message "%s: Performed %s edits" (current-buffer) (length edits))) + (with-current-buffer source + (save-excursion + (save-restriction + (narrow-to-region beg end) + (replace-buffer-contents temp))) + (progress-reporter-update reporter (cl-incf done))))))) + (mapcar (eglot--lambda (&key range newText) + (cons newText (eglot--range-region range 'markers))) + edits)) + (progress-reporter-done reporter)))) (defun eglot--apply-workspace-edit (wedit &optional confirm) "Apply the workspace edit WEDIT. If CONFIRM, ask user first."