From 2972be24d48e78746da79ba8e24e8b488c9880de Mon Sep 17 00:00:00 2001 From: Jim-wiselike Date: Sun, 3 Jun 2018 21:26:55 +0800 Subject: [PATCH] Modify the display width for Chinese characters and so on (#145) The display width will not be right if there have Chinese characters in the display. It will overflow the line, if the Chinese characters are at the end of a line. And makes "lines" value not the right number of line rows, which makes "239: fmt.Fprintf" produce wrong output. --- complete.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/complete.go b/complete.go index d1351f7..c08c994 100644 --- a/complete.go +++ b/complete.go @@ -221,7 +221,7 @@ func (o *opCompleter) CompleteRefresh() { } buf.WriteString(string(same)) buf.WriteString(string(c)) - buf.Write(bytes.Repeat([]byte(" "), colWidth-len(c)-len(same))) + buf.Write(bytes.Repeat([]byte(" "), colWidth-runes.WidthAll(c)-runes.WidthAll(same))) if inSelect { buf.WriteString("\033[0m")