Skip to content

Commit da065b5

Browse files
committed
Add comments
I got confused when I investigated the bug that was fixed in the previous commit, so hopefully these will be helpful for the next person reading this code.
1 parent bcfb4e1 commit da065b5

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

pkg/gui/controllers/helpers/confirmation_helper.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ func (self *ConfirmationHelper) getPopupPanelDimensionsAux(contentWidth int, con
130130
height/2 + panelHeight/2 - 1
131131
}
132132

133+
// Returns the outer width of the view, including its frame. To decide how to wrap text, subtract 2.
134+
// Also, note that X1-X0 of the view is one less than this.
133135
func (self *ConfirmationHelper) getPopupPanelWidth(maxWidth int) int {
134136
width, _ := self.c.GocuiGui().Size()
135137
// we want a minimum width up to a point, then we do it based on ratio, but only up to the given max width
@@ -418,6 +420,8 @@ func (self *ConfirmationHelper) ResizeCommitMessagePanels(parentPopupContext typ
418420
contentWidth := panelWidth - 2 // minus 2 for the frame
419421
content := self.c.Views().CommitDescription.TextArea.GetContent()
420422
summaryViewHeight := 3
423+
// The width we pass to getMessageHeight is irrelevant because we don't wrap the text to the
424+
// view width. If we did, we'd have to subtract 2 for the view frame.
421425
contentHeight := getMessageHeight(false, true, content, contentWidth, self.c.Views().CommitDescription.TabWidth)
422426
minHeight := 7
423427
if contentHeight < minHeight {

0 commit comments

Comments
 (0)