Skip to content

Commit e965639

Browse files
committed
fix(lisp): ANSI reset on last character
1 parent 91b4965 commit e965639

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lisp/_prepare.el

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,21 @@ and INHERIT-INPUT-METHOD see function `read-string' for more information."
412412
For arguments OLD, NEW and S; see the function `eask-s-replace'
413413
for more information."
414414
(if-let* ((data (eask-ansi-codes s))
415-
(start (nth 1 data))
416-
(end (nth 0 data))
417415
(splits (split-string s (regexp-quote old))))
418-
(mapconcat #'identity splits (concat start new end))
416+
(let* ((result (nth 0 splits))
417+
(index 1)
418+
(base 0)
419+
(reset (car (last data))))
420+
(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
425+
(nth index splits))))
426+
(cl-incf base 2)
427+
(cl-incf index))
428+
;; Just ensure the last character is reset.
429+
(concat result reset))
419430
(eask-s-replace old new s)))
420431

421432
;;

0 commit comments

Comments
 (0)