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.
This commit is contained in:
Jim-wiselike 2018-06-03 21:26:55 +08:00 committed by chzyer
parent f6d7a1f6fb
commit 2972be24d4
1 changed files with 1 additions and 1 deletions

View File

@ -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")