From f50a7058d6734b8213fb8bbe6a293b2ffd485eed Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 1 Sep 2023 20:28:56 +0900 Subject: Fix center-alignment of border/preview label Fix #3421 --- src/terminal.go | 2 +- src/util/util_test.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/terminal.go b/src/terminal.go index c7e86209..6418a5df 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -781,7 +781,7 @@ func (t *Terminal) ansiLabelPrinter(str string, color *tui.ColorPair, fill bool) window.CPrint(*color, str) } } - return printFn, len(text) + return printFn, length } // Printer that correctly handles ANSI color codes and tab characters diff --git a/src/util/util_test.go b/src/util/util_test.go index 27e7a049..42a66636 100644 --- a/src/util/util_test.go +++ b/src/util/util_test.go @@ -184,3 +184,10 @@ func TestRepeatToFill(t *testing.T) { t.Error("Expected:", strings.Repeat("abcde", 4)+"abcde"[:2]) } } + +func TestStringWidth(t *testing.T) { + w := StringWidth("─") + if w != 1 { + t.Errorf("Expected: %d, Actual: %d", 1, w) + } +} -- cgit v1.2.3