From 7253a45c216920796948ca2e8359ab9451bf011b Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 8 Sep 2026 09:51:57 +0200 Subject: [PATCH] Let a popup panel have an odd width The left and the right edge of a popup panel were each derived by halving the panel's width, so a panel that asked for an odd width lost a column and came out one column left of centre. Resizing the window then moved the panel's right edge only every other column, and left a gap of one column between the panel and where it should end half of the time. Derive the right edge from the left one and the width instead, the way the branch above already does it for a popup that has a parent. This also means that a panel of an odd width is now as wide as the width its text was wrapped to. Co-authored-by: Claude Opus 5 (1M context) --- pkg/gui/controllers/helpers/confirmation_helper.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/gui/controllers/helpers/confirmation_helper.go b/pkg/gui/controllers/helpers/confirmation_helper.go index 61499af98..ca25204a6 100644 --- a/pkg/gui/controllers/helpers/confirmation_helper.go +++ b/pkg/gui/controllers/helpers/confirmation_helper.go @@ -118,13 +118,12 @@ func (self *ConfirmationHelper) getPopupPanelDimensionsAux(contentWidth int, con y0 += 1 return x0, y0, x0 + panelWidth - 1, y0 + panelHeight - 1 } - return width/2 - panelWidth/2, - height/2 - panelHeight/2 - panelHeight%2, - // Currently, X1/Y1 of a gocui view is one less than you would expect based on its - // width/height, so we need to subtract 1 here. See - // https://github.com/jesseduffield/lazygit/commit/f6f2a52dee8bba3ebd7e3b34b4b7c7d3e3795f3e - width/2 + panelWidth/2 - 1, - height/2 + panelHeight/2 - 1 + x0 := (width - panelWidth) / 2 + y0 := height/2 - panelHeight/2 - panelHeight%2 + // Currently, X1/Y1 of a gocui view is one less than you would expect based on its + // width/height, so we need to subtract 1 here. See + // https://github.com/jesseduffield/lazygit/commit/f6f2a52dee8bba3ebd7e3b34b4b7c7d3e3795f3e + return x0, y0, x0 + panelWidth - 1, y0 + panelHeight - 1 } const (