From 5ed31309b6d0db94ccd566914653d367f4577c64 Mon Sep 17 00:00:00 2001 From: historia Date: Fri, 28 Aug 2026 04:45:29 -0400 Subject: fix: japanese characters not truncated correctly in tui terminal output --- app/tests/test_runview.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/tests/test_runview.py') diff --git a/app/tests/test_runview.py b/app/tests/test_runview.py index 8feeee1..3f77ed0 100644 --- a/app/tests/test_runview.py +++ b/app/tests/test_runview.py @@ -62,10 +62,21 @@ class FormatTests(_FakeTui, unittest.TestCase): self.assertEqual(runview._fit("hello", 3), "he~") self.assertEqual(runview._fit("hi", 10), "hi") + def test_fit_truncates_wide_characters_by_display_columns(self): + # Japanese characters fill two terminal cells each, so fitting + # by character count would let lines overflow their pane. + self.assertEqual(runview._fit("你好", 4), "你好") + self.assertEqual(runview._fit("你好你好", 5), "你好~") + self.assertEqual(runview._fit("こんにちは", 3), "こ~") + def test_wrap_wraps_on_word_boundaries(self): self.assertEqual(runview._wrap("aaaa bbbb cccc dddd", 12), ["aaaa bbbb", "cccc dddd"]) + def test_wrap_counts_wide_characters_as_two_columns(self): + self.assertEqual(runview._wrap("日本語 テスト", 10), + ["日本語", "テスト"]) + class StateTransitionTests(_FakeTui, unittest.TestCase): def test_boot_flow_starting_to_ready(self): -- cgit v1.2.3