Repository: jesseduffield/lazygit (language: go)

Issue:
unstaged panel can be maximized, but staged panel cannot.
**Describe the bug**
unstaged panel can be maximized, but staged panel cannot.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to any git repo
2. make multiple line changes
3. open lazygit, stage any of the changes
4. focus on staged, press + to test, then focus on unstaged, press + to test
5. staged panel cannot be maximized, instead, the panel keeps shrinking when hitting '+'

**Expected behavior**
staged panel should change screenmode like unstaged panel

**Screenshots**

![staged panel cannot be maximized](https://github.com/jesseduffield/lazygit/assets/42881610/3d218dd8-d8b3-4b47-a398-d90a59bdcee9)

If applicable, add screenshots to help explain your problem.

**Version info:**
```
commit=6fcb7eb8bb616c170506312870b3bf15f3dbe37c, build date=2024-05-19T10:15:28Z, build source=binaryRelease, version=0.42.0, os=linux, ar
ch=amd64, git version=2.45.1
```




Discussion / hints:
Reproduced this. Initial findings seem to be when focused the staged changes pane, the '+' behaviour has the same effect as on the 'files' pane.

Fix patch:
diff --git a/pkg/gui/controllers/helpers/window_arrangement_helper.go b/pkg/gui/controllers/helpers/window_arrangement_helper.go
index 5c17083f7f4..0eb7cdb4aa3 100644
--- a/pkg/gui/controllers/helpers/window_arrangement_helper.go
+++ b/pkg/gui/controllers/helpers/window_arrangement_helper.go
@@ -216,6 +216,15 @@ func mainSectionChildren(args WindowArrangementArgs) []*boxlayout.Box {
 		}
 	}
 
+	if args.CurrentWindow == "secondary" && args.ScreenMode == types.SCREEN_FULL {
+		return []*boxlayout.Box{
+			{
+				Window: "secondary",
+				Weight: 1,
+			},
+		}
+	}
+
 	return []*boxlayout.Box{
 		{
 			Window: "main",
@@ -239,7 +248,7 @@ func getMidSectionWeights(args WindowArrangementArgs) (int, int) {
 		mainSectionWeight = 5 // need to shrink side panel to make way for main panels if side-by-side
 	}
 
-	if args.CurrentWindow == "main" {
+	if args.CurrentWindow == "main" || args.CurrentWindow == "secondary" {
 		if args.ScreenMode == types.SCREEN_HALF || args.ScreenMode == types.SCREEN_FULL {
 			sideSectionWeight = 0
 		}
diff --git a/pkg/integration/components/view_driver.go b/pkg/integration/components/view_driver.go
index 4d8e75217d2..e40c0c5f119 100644
--- a/pkg/integration/components/view_driver.go
+++ b/pkg/integration/components/view_driver.go
@@ -565,7 +565,7 @@ func (self *ViewDriver) IsVisible() *ViewDriver {
 
 func (self *ViewDriver) IsInvisible() *ViewDriver {
 	self.t.assertWithRetries(func() (bool, string) {
-		return !self.getView().Visible, fmt.Sprintf("%s: Expected view to be visible, but it was not", self.context)
+		return !self.getView().Visible, fmt.Sprintf("%s: Expected view to be invisible, but it was not", self.context)
 	})
 
 	return self


Test patch:
diff --git a/pkg/integration/tests/staging/diff_change_screen_mode.go b/pkg/integration/tests/staging/diff_change_screen_mode.go
new file mode 100644
index 00000000000..b42439cc8c5
--- /dev/null
+++ b/pkg/integration/tests/staging/diff_change_screen_mode.go
@@ -0,0 +1,47 @@
+package staging
+
+import (
+	"github.com/jesseduffield/lazygit/pkg/config"
+	. "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var DiffChangeScreenMode = NewIntegrationTest(NewIntegrationTestArgs{
+	Description:  "Change the staged changes screen mode",
+	ExtraCmdArgs: []string{},
+	Skip:         false,
+	SetupConfig:  func(config *config.AppConfig) {},
+	SetupRepo: func(shell *Shell) {
+		shell.CreateFile("file", "first line\nsecond line")
+	},
+	Run: func(t *TestDriver, keys config.KeybindingConfig) {
+		t.Views().Files().
+			Focus().
+			PressEnter()
+
+		t.Views().Staging().
+			IsFocused().
+			PressPrimaryAction().
+			Title(Equals("Unstaged changes")).
+			Content(Contains("+second line").DoesNotContain("+first line")).
+			PressTab()
+
+		t.Views().StagingSecondary().
+			IsFocused().
+			Title(Equals("Staged changes")).
+			Content(Contains("+first line").DoesNotContain("+second line")).
+			Press(keys.Universal.NextScreenMode).
+			Tap(func() {
+				t.Views().AppStatus().
+					IsInvisible()
+				t.Views().Staging().
+					IsVisible()
+			}).
+			Press(keys.Universal.NextScreenMode).
+			Tap(func() {
+				t.Views().AppStatus().
+					IsInvisible()
+				t.Views().Staging().
+					IsInvisible()
+			})
+	},
+})
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index c1e153a2b41..d4ebd40265f 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -245,6 +245,7 @@ var tests = []*components.IntegrationTest{
 	reflog.DoNotShowBranchMarkersInReflogSubcommits,
 	reflog.Patch,
 	reflog.Reset,
+	staging.DiffChangeScreenMode,
 	staging.DiffContextChange,
 	staging.DiscardAllChanges,
 	staging.Search,