fix(cli): properly overwrite last line of output
Before this, text that extended past the new line's length would persist, causing garbled output like this: > Ensuring packages are installed and built... > Updating recipe repos... > Cloning org-appear...r emacsmirror-mirror... - No packages need attention Which might lead you to believe org-appear is being cloned from emacsmirror-mirror, but the full output is actually: > Ensuring packages are installed and built... > Updating recipe repos... > Updating recipes for melpa... > Updating recipes for nongnu-elpa... > Updating recipes for gnu-elpa-mirror... > Updating recipes for el-get... > Updating recipes for emacsmirror-mirror... > Cloning org-appear... - No packages need attention
This commit is contained in:
parent
7c5d8641a1
commit
5852b2ecf5
2 changed files with 40 additions and 34 deletions
|
@ -308,18 +308,25 @@ based on the print level of the message. For example:
|
|||
(defun doom-print--indent (text &optional prefix)
|
||||
"Indent TEXT by WIDTH spaces. If ARGS, format TEXT with them."
|
||||
(with-temp-buffer
|
||||
(let ((width
|
||||
(cond ((null prefix)
|
||||
doom-print-indent-increment)
|
||||
((integerp prefix)
|
||||
prefix)
|
||||
((length (ansi-color-filter-apply (format "%s" prefix)))))))
|
||||
(insert (format "%s" (or text "")))
|
||||
(let* ((re "^\\( *\\)\r")
|
||||
(line-feed (if (stringp text) (string-match-p re text)))
|
||||
(width (cond ((null prefix) doom-print-indent-increment)
|
||||
((integerp prefix) prefix)
|
||||
((length (ansi-color-filter-apply (format "%s" prefix)))))))
|
||||
(insert
|
||||
(if text
|
||||
(replace-regexp-in-string re "\\1\033[K" (format "%s" text))
|
||||
""))
|
||||
(indent-rigidly (point-min) (point-max) width)
|
||||
(when (stringp prefix)
|
||||
(goto-char (point-min))
|
||||
(delete-char width)
|
||||
(insert prefix))
|
||||
(save-excursion
|
||||
(when line-feed
|
||||
(goto-char (point-min))
|
||||
(insert "\r")))
|
||||
(save-excursion
|
||||
(when (stringp prefix)
|
||||
(goto-char (point-min))
|
||||
(delete-char (+ width (if line-feed 1 0)))
|
||||
(insert prefix)))
|
||||
(buffer-string))))
|
||||
|
||||
;;;###autoload
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue