From 3610f1341892db54fa3e9eddace008ea44560b64 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 27 Nov 2024 09:29:12 +0100 Subject: [PATCH] Fix several bugs in wrapMessageToWidth This corresponds to the following fixes in gocui's lineWrap function: - https://github.com/jesseduffield/gocui/pull/67/commits/86cf561ef493 - https://github.com/jesseduffield/gocui/pull/67/commits/24746d5cd6ee - https://github.com/jesseduffield/gocui/pull/67/commits/4b97941c4ec6 --- pkg/gui/controllers/helpers/confirmation_helper.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/gui/controllers/helpers/confirmation_helper.go b/pkg/gui/controllers/helpers/confirmation_helper.go index 7b0b8ddb2..dbdc985e8 100644 --- a/pkg/gui/controllers/helpers/confirmation_helper.go +++ b/pkg/gui/controllers/helpers/confirmation_helper.go @@ -87,16 +87,14 @@ func wrapMessageToWidth(wrap bool, message string, width int) []string { wrappedLines = append(wrappedLines, line[offset:i]) offset = i n = rw - } else if lastWhitespaceIndex != -1 && lastWhitespaceIndex+1 != i { + } else if lastWhitespaceIndex != -1 { if line[lastWhitespaceIndex] == '-' { wrappedLines = append(wrappedLines, line[offset:lastWhitespaceIndex+1]) - offset = lastWhitespaceIndex + 1 - n = i - lastWhitespaceIndex } else { wrappedLines = append(wrappedLines, line[offset:lastWhitespaceIndex]) - offset = lastWhitespaceIndex + 1 - n = i - lastWhitespaceIndex + 1 } + offset = lastWhitespaceIndex + 1 + n = runewidth.StringWidth(line[offset : i+1]) } else { wrappedLines = append(wrappedLines, line[offset:i]) offset = i