From a0ae5fc5349063fb9b0a3de04be555b3757c1f4b Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Mon, 31 Dec 2018 08:53:11 +0800 Subject: Fix incorrect wrap of mixed wide and ascii chars --- util/text/text_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'util/text/text_test.go') diff --git a/util/text/text_test.go b/util/text/text_test.go index 480b1f1f..374ced16 100644 --- a/util/text/text_test.go +++ b/util/text/text_test.go @@ -5,7 +5,6 @@ import ( "testing" ) - func TestWrap(t *testing.T) { cases := []struct { Input, Output string @@ -102,6 +101,18 @@ func TestWrap(t *testing.T) { "一只敏捷的\x1b[31m狐\n狸跳过\x1b[0m了一只\n懒狗。", 12, }, + // Handle mixed wide and short characters + { + "敏捷 A quick 的狐狸 fox 跳过 jumps over a lazy 了一只懒狗 dog。", + "敏捷 A quick\n的狐狸 fox\n跳过 jumps\nover a lazy\n了一只懒狗\ndog。", + 12, + }, + // Handle mixed wide and short characters with color + { + "敏捷 A \x1b31mquick 的狐狸 fox 跳\x1b0m过 jumps over a lazy 了一只懒狗 dog。", + "敏捷 A \x1b31mquick\n的狐狸 fox\n跳\x1b0m过 jumps\nover a lazy\n了一只懒狗\ndog。", + 12, + }, } for i, tc := range cases { -- cgit