From 4f8f6f1ca3658550f45a651cb1b33b398811344f Mon Sep 17 00:00:00 2001 From: Tatsuro YOKOTA Date: Fri, 21 Jul 2017 11:18:15 +0900 Subject: [PATCH] multi-byte characters are overlapped in prompt message (#745) * modified messenger.Display * modified messenger.Display --- cmd/micro/messenger.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/micro/messenger.go b/cmd/micro/messenger.go index 3fda5368..796f1e81 100644 --- a/cmd/micro/messenger.go +++ b/cmd/micro/messenger.go @@ -9,6 +9,7 @@ import ( "github.com/zyedidia/clipboard" "github.com/zyedidia/tcell" + "github.com/mattn/go-runewidth" ) // TermMessage sends a message to the user in the terminal. This usually occurs before @@ -463,8 +464,10 @@ func (m *Messenger) Display() { if m.hasMessage { if m.hasPrompt || globalSettings["infobar"].(bool) { runes := []rune(m.message + m.response) + posx := 0 for x := 0; x < len(runes); x++ { - screen.SetContent(x, h-1, runes[x], nil, m.style) + screen.SetContent(posx, h-1, runes[x], nil, m.style) + posx += runewidth.RuneWidth(runes[x]) } } }