Skip to content

Commit b0cd5c6

Browse files
committed
fix(lisp): ansi follow the last one
1 parent e965639 commit b0cd5c6

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

lisp/_prepare.el

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -411,22 +411,20 @@ and INHERIT-INPUT-METHOD see function `read-string' for more information."
411411
412412
For arguments OLD, NEW and S; see the function `eask-s-replace'
413413
for more information."
414-
(if-let* ((data (eask-ansi-codes s))
415-
(splits (split-string s (regexp-quote old))))
416-
(let* ((result (nth 0 splits))
414+
(if-let* ((splits (split-string s (regexp-quote old))))
415+
(let* ((reset "\e[0m")
416+
(result (nth 0 splits))
417417
(index 1)
418-
(base 0)
419-
(reset (car (last data))))
418+
(last))
420419
(while (< index (length splits))
421-
(let ((start (nth base data))
422-
(end (nth (1+ base) data))) ; \e[0m
423-
(setq result (concat result
424-
end new start
420+
(let* ((data (eask-ansi-codes result)))
421+
(setq last (car (last data))
422+
result (concat result
423+
(if (null last) "" reset) new last
425424
(nth index splits))))
426-
(cl-incf base 2)
427425
(cl-incf index))
428426
;; Just ensure the last character is reset.
429-
(concat result reset))
427+
(concat result (if (null last) "" reset)))
430428
(eask-s-replace old new s)))
431429

432430
;;

0 commit comments

Comments
 (0)