From e33c41b0122914b61491a5c24c805401f1e40224 Mon Sep 17 00:00:00 2001 From: c-bata Date: Sun, 24 Jun 2018 14:19:00 +0900 Subject: [PATCH] Delete break line characters from Suggests --- completion.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/completion.go b/completion.go index afb88ed..5f69803 100644 --- a/completion.go +++ b/completion.go @@ -108,6 +108,12 @@ func (c *CompletionManager) update() { } } +func deleteBreakLineCharacters(s string) string { + s = strings.Replace(s, "\n", "", -1) + s = strings.Replace(s, "\r", "", -1) + return s +} + func formatTexts(o []string, max int, prefix, suffix string) (new []string, width int) { l := len(o) n := make([]string, l) @@ -117,6 +123,8 @@ func formatTexts(o []string, max int, prefix, suffix string) (new []string, widt lenShorten := runewidth.StringWidth(shortenSuffix) min := lenPrefix + lenSuffix + lenShorten for i := 0; i < l; i++ { + o[i] = deleteBreakLineCharacters(o[i]) + w := runewidth.StringWidth(o[i]) if width < w { width = w