Skip to content

Commit 26db25b

Browse files
authored
Fix scrollbar in certain popup panels (e.g. the intro message for new users) (#4804)
When showing a confirmation whose text ends 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.
2 parents c0dcf7d + 09e2bfa commit 26db25b

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
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)

pkg/utils/lines_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -405,20 +405,6 @@ func TestWrapViewLinesToWidth(t *testing.T) {
405405
expectedWrappedLinesIndices: []int{0, 1, 2},
406406
expectedOriginalLinesIndices: []int{0, 1, 2},
407407
},
408-
{
409-
name: "Avoid blank line at end if not editable",
410-
wrap: true,
411-
editable: false,
412-
text: "First\nSecond\nThird\n",
413-
width: 10,
414-
expectedWrappedLines: []string{
415-
"First",
416-
"Second",
417-
"Third",
418-
},
419-
expectedWrappedLinesIndices: []int{0, 1, 2},
420-
expectedOriginalLinesIndices: []int{0, 1, 2},
421-
},
422408
{
423409
name: "Keep blank line at end if editable",
424410
wrap: true,

0 commit comments

Comments
 (0)