Skip to content

Commit 09e2bfa

Browse files
committed
Trim trailing newlines when showing confirmations
When showing a confirmation whose text ended with a line feed, we would make the popup panel one line less tall than it needs to be, so it would show a scroll bar. One example where this occurred is the very first popup that users ever see (the "seriously you rock" message for new users); that's a pretty bad first impression. This happens because our code to suppress trailing newlines in views doesn't work for styled text, and the text in confirmations is bold. This code checks if the last character of the text is a line feed, and in this case it isn't; the escape sequence for turning bold off comes after it. We should really fix this by improving that mechanism, but this would require some tricky logic, so as a quick fix, trim trailing (and leading) linefeeds from the text that we display in a confirmation, before making it bold.
1 parent a364ee5 commit 09e2bfa

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/gui/controllers/helpers/confirmation_helper.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package helpers
33
import (
44
goContext "context"
55
"fmt"
6+
"strings"
67

78
"github.com/jesseduffield/lazygit/pkg/gui/style"
89
"github.com/jesseduffield/lazygit/pkg/gui/types"
@@ -168,7 +169,7 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ
168169
confirmationView.RenderTextArea()
169170
} else {
170171
self.c.ResetViewOrigin(confirmationView)
171-
self.c.SetViewContent(confirmationView, style.AttrBold.Sprint(opts.Prompt))
172+
self.c.SetViewContent(confirmationView, style.AttrBold.Sprint(strings.TrimSpace(opts.Prompt)))
172173
}
173174

174175
self.setKeyBindings(cancel, opts)

0 commit comments

Comments
 (0)