aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-26 12:09:55 -0400
committerCraig Jennings <c@cjennings.net>2026-06-26 12:09:55 -0400
commit607b219e32b15a88963cf94d3d04ba52a5bd861c (patch)
treef5de848c6a2efe90d2d13d4d6966da7286001d1a /tests
parent7b42f3f6928c7d645e5233796142590e980aad84 (diff)
downloaddotemacs-607b219e32b15a88963cf94d3d04ba52a5bd861c.tar.gz
dotemacs-607b219e32b15a88963cf94d3d04ba52a5bd861c.zip
feat(eat): reset SGR at newline to contain unterminated-color bleed
Claude Code and similar inline TUIs sometimes truncate a colored span without emitting a reset; the unterminated color then bleeds onto every following line in the EAT buffer. Advise eat-term-process-output to inject an SGR reset before each newline, containing the bleed to its own line. Validated in real EAT and via an ansi-color proxy: it contains the bleed and leaves per-line coloring intact, since programs re-open their color on each line. Gated by cj/eat-reset-sgr-at-newline (default on) so it can be disabled if a program ever carries one color across newlines without re-opening it.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-term-tmux-history.el11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test-term-tmux-history.el b/tests/test-term-tmux-history.el
index 13e3e1715..a5f5c93cd 100644
--- a/tests/test-term-tmux-history.el
+++ b/tests/test-term-tmux-history.el
@@ -305,5 +305,16 @@ the EAT window line-scrolls instead of recentering on full-frame redraws."
(should (= scroll-margin 0))
(should (null auto-window-vscroll))))
+(ert-deftest test-term-eat-reset-sgr-at-newline ()
+ "Normal: the SGR-reset advice injects a reset before each newline when enabled
+\(containing an unterminated color), and passes output through unchanged when
+disabled."
+ (let ((cj/eat-reset-sgr-at-newline t))
+ (should (equal (cj/--eat-reset-sgr-at-newline (list (quote term) "a\nb\n"))
+ (list (quote term) "a\e[0m\nb\e[0m\n"))))
+ (let ((cj/eat-reset-sgr-at-newline nil))
+ (should (equal (cj/--eat-reset-sgr-at-newline (list (quote term) "a\nb\n"))
+ (list (quote term) "a\nb\n")))))
+
(provide 'test-term-tmux-history)
;;; test-term-tmux-history.el ends here