1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-29 22:48:24 +02:00

Change side panel width calculation to work for larger numbers

This technically is a breaking change for some existing numbers,
but it stays the same for default case, and isn't much different for
others
This commit is contained in:
Chris McDonnell
2025-02-19 00:19:59 -05:00
committed by Jesse Duffield
parent e62aeb99ed
commit 9d0740427e
2 changed files with 88 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ package helpers
import (
"fmt"
"math"
"strings"
"github.com/jesseduffield/lazycore/pkg/boxlayout"
@@ -237,14 +238,14 @@ func mainSectionChildren(args WindowArrangementArgs) []*boxlayout.Box {
}
func getMidSectionWeights(args WindowArrangementArgs) (int, int) {
// we originally specified this as a ratio i.e. .20 would correspond to a weight of 1 against 4
sidePanelWidthRatio := args.UserConfig.Gui.SidePanelWidth
// we could make this better by creating ratios like 2:3 rather than always 1:something
mainSectionWeight := int(1/sidePanelWidthRatio) - 1
sideSectionWeight := 1
// Using 120 so that the default of 0.3333 will remain consistent with previous behavior
const maxColumnCount = 120
mainSectionWeight := int(math.Round(maxColumnCount * (1 - sidePanelWidthRatio)))
sideSectionWeight := int(math.Round(maxColumnCount * sidePanelWidthRatio))
if splitMainPanelSideBySide(args) {
mainSectionWeight = 5 // need to shrink side panel to make way for main panels if side-by-side
mainSectionWeight = sideSectionWeight * 5 // need to shrink side panel to make way for main panels if side-by-side
}
if args.CurrentWindow == "main" || args.CurrentWindow == "secondary" {
@@ -254,9 +255,9 @@ func getMidSectionWeights(args WindowArrangementArgs) (int, int) {
} else {
if args.ScreenMode == types.SCREEN_HALF {
if args.UserConfig.Gui.EnlargedSideViewLocation == "top" {
mainSectionWeight = 2
mainSectionWeight = sideSectionWeight * 2
} else {
mainSectionWeight = 1
mainSectionWeight = sideSectionWeight
}
} else if args.ScreenMode == types.SCREEN_FULL {
mainSectionWeight = 0