Repository: jesseduffield/lazygit (language: go)

Issue:
Option to always show unstaged/staged panels
I like to scroll through files and look at either all staged, or all unstaged, while also seeing the relation to each other. This request is to make this at least an option.


Discussion / hints:
(Sorry, added this to the wrong issue before)

Makes sense, I've added a good-first-issue label. Relevant place to update the code is in the `filesRenderToMain` function in `pkg/gui/files_panel.go`. We need to be unconditionally setting `refreshOpts.secondary` to a value (even if it's rendering nothing) if a user config value is set that says we should always show staged and unstaged changes in separate panels. 

We could call the user config 'SplitDiff' with 'always' and 'auto' as possible values. We can chuck it on GuiConfig in `pkg/config/user_config.go`
@jesseduffield 
Hi! I'd  like to tackle this issue!
@HiromasaNojima awesome! Reach out if you need any pointers

Fix patch:
diff --git a/docs/Config.md b/docs/Config.md
index 44c6ace30cd..f8ab633627e 100644
--- a/docs/Config.md
+++ b/docs/Config.md
@@ -54,6 +54,7 @@ gui:
   showCommandLog: true
   showIcons: false
   commandLogSize: 8
+  splitDiff: 'auto' # one of 'auto' | 'always'
 git:
   paging:
     colorArg: always
diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go
index 900dd2e97f4..5c90f85a7ec 100644
--- a/pkg/config/user_config.go
+++ b/pkg/config/user_config.go
@@ -46,6 +46,7 @@ type GuiConfig struct {
 	ShowBottomLine           bool               `yaml:"showBottomLine"`
 	ShowIcons                bool               `yaml:"showIcons"`
 	CommandLogSize           int                `yaml:"commandLogSize"`
+	SplitDiff                string             `yaml:"splitDiff"`
 }
 
 type ThemeConfig struct {
@@ -360,6 +361,7 @@ func GetDefaultConfig() *UserConfig {
 			ShowRandomTip:            true,
 			ShowIcons:                false,
 			CommandLogSize:           8,
+			SplitDiff:                "auto",
 		},
 		Git: GitConfig{
 			Paging: PagingConfig{
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index 765e33e4cca..d4e156ccb3a 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -53,31 +53,32 @@ func (gui *Gui) filesRenderToMain() error {
 
 	gui.resetMergeStateWithLock()
 
-	cmdObj := gui.git.WorkingTree.WorktreeFileDiffCmdObj(node, false, !node.GetHasUnstagedChanges() && node.GetHasStagedChanges(), gui.IgnoreWhitespaceInDiffView)
-
 	mainContext := gui.State.Contexts.Normal
 	if node.File != nil {
 		mainContext = gui.State.Contexts.Staging
 	}
 
+	split := gui.c.UserConfig.Gui.SplitDiff == "always" || (node.GetHasUnstagedChanges() && node.GetHasStagedChanges())
+	mainShowsStaged := !split && node.GetHasStagedChanges()
+
+	cmdObj := gui.git.WorkingTree.WorktreeFileDiffCmdObj(node, false, mainShowsStaged, gui.IgnoreWhitespaceInDiffView)
 	refreshOpts := refreshMainOpts{main: &viewUpdateOpts{
 		title:   gui.c.Tr.UnstagedChanges,
 		task:    NewRunPtyTask(cmdObj.GetCmd()),
 		context: mainContext,
 	}}
+	if mainShowsStaged {
+		refreshOpts.main.title = gui.c.Tr.StagedChanges
+	}
 
-	if node.GetHasUnstagedChanges() {
-		if node.GetHasStagedChanges() {
-			cmdObj := gui.git.WorkingTree.WorktreeFileDiffCmdObj(node, false, true, gui.IgnoreWhitespaceInDiffView)
+	if split {
+		cmdObj := gui.git.WorkingTree.WorktreeFileDiffCmdObj(node, false, true, gui.IgnoreWhitespaceInDiffView)
 
-			refreshOpts.secondary = &viewUpdateOpts{
-				title:   gui.c.Tr.StagedChanges,
-				task:    NewRunPtyTask(cmdObj.GetCmd()),
-				context: mainContext,
-			}
+		refreshOpts.secondary = &viewUpdateOpts{
+			title:   gui.c.Tr.StagedChanges,
+			task:    NewRunPtyTask(cmdObj.GetCmd()),
+			context: mainContext,
 		}
-	} else {
-		refreshOpts.main.title = gui.c.Tr.StagedChanges
 	}
 
 	return gui.refreshMainViews(refreshOpts)


Test patch: