diff --git a/pkg/gui/controllers/helpers/window_arrangement_helper.go b/pkg/gui/controllers/helpers/window_arrangement_helper.go index 393b0ffb134..1bf00248b29 100644 --- a/pkg/gui/controllers/helpers/window_arrangement_helper.go +++ b/pkg/gui/controllers/helpers/window_arrangement_helper.go @@ -249,8 +249,9 @@ func getMidSectionWeights(args WindowArrangementArgs) (int, int) { } if args.CurrentWindow == "main" || args.CurrentWindow == "secondary" { - if args.ScreenMode == types.SCREEN_HALF || args.ScreenMode == types.SCREEN_FULL { + if args.ScreenMode == types.SCREEN_HALF || args.ScreenMode == types.SCREEN_FULL || mainSectionWeight == 0 { sideSectionWeight = 0 + mainSectionWeight = 1 } } else { if args.ScreenMode == types.SCREEN_HALF { diff --git a/pkg/gui/controllers/helpers/window_arrangement_helper_test.go b/pkg/gui/controllers/helpers/window_arrangement_helper_test.go index 6274fae2be6..207e0eb115b 100644 --- a/pkg/gui/controllers/helpers/window_arrangement_helper_test.go +++ b/pkg/gui/controllers/helpers/window_arrangement_helper_test.go @@ -283,6 +283,87 @@ func TestGetWindowDimensions(t *testing.T) { B: information `, }, + { + name: "1.0 SidePanelWidth", + mutateArgs: func(args *WindowArrangementArgs) { + args.UserConfig.Gui.SidePanelWidth = 1.0 + }, + expected: ` + ╭status───────────────────────────────────────────────────────────────────╮ + │ │ + ╰─────────────────────────────────────────────────────────────────────────╯ + ╭files────────────────────────────────────────────────────────────────────╮ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + ╰─────────────────────────────────────────────────────────────────────────╯ + ╭branches─────────────────────────────────────────────────────────────────╮ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + ╰─────────────────────────────────────────────────────────────────────────╯ + ╭commits──────────────────────────────────────────────────────────────────╮ + │ │ + │ │ + │ │ + │ │ + │ │ + ╰─────────────────────────────────────────────────────────────────────────╯ + ╭stash────────────────────────────────────────────────────────────────────╮ + │ │ + ╰─────────────────────────────────────────────────────────────────────────╯ + A + A: statusSpacer1 + B: information + `, + }, + { + name: "1.0 SidePanelWidth main view focused", + mutateArgs: func(args *WindowArrangementArgs) { + args.UserConfig.Gui.SidePanelWidth = 1.0 + args.CurrentWindow = "main" + }, + expected: ` + ╭main─────────────────────────────────────────────────────────────────────╮ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + ╰─────────────────────────────────────────────────────────────────────────╯ + A + A: statusSpacer1 + B: information + `, + }, { name: "half screen mode, enlargedSideViewLocation left", mutateArgs: func(args *WindowArrangementArgs) { diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 23a05fa5c8a..2f8a88f2145 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -412,6 +412,7 @@ var tests = []*components.IntegrationTest{ ui.ModeSpecificKeybindingSuggestions, ui.OpenLinkFailure, ui.RangeSelect, + ui.SidePanelWidth1, ui.SwitchTabFromMenu, ui.SwitchTabWithPanelJumpKeys, undo.UndoCheckoutAndDrop, diff --git a/pkg/integration/tests/ui/side_panel_width_1.go b/pkg/integration/tests/ui/side_panel_width_1.go new file mode 100644 index 00000000000..a4d5fca29de --- /dev/null +++ b/pkg/integration/tests/ui/side_panel_width_1.go @@ -0,0 +1,29 @@ +package ui + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SidePanelWidth1 = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Verify that setting sidePanelWidth to 1.0 doesn't crash when navigating to commit files", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) { + config.GetUserConfig().Gui.SidePanelWidth = 1.0 + }, + SetupRepo: func(shell *Shell) { + shell.CreateFileAndAdd("file1.txt", "content") + shell.Commit("first commit") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits().Focus(). + Press(keys.Universal.NextScreenMode). + Press(keys.Universal.GoInto) + + t.Views().CommitFiles(). + Press(keys.Universal.GoInto) + + t.Views().PatchBuilding().Content(Contains("+content")) + }, +})