diff --git a/docs/Config.md b/docs/Config.md index 44c6ace30..f8ab63362 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 900dd2e97..5c90f85a7 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 765e33e4c..d4e156ccb 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -53,33 +53,34 @@ 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 node.GetHasUnstagedChanges() { - if node.GetHasStagedChanges() { - cmdObj := gui.git.WorkingTree.WorktreeFileDiffCmdObj(node, false, true, gui.IgnoreWhitespaceInDiffView) - - refreshOpts.secondary = &viewUpdateOpts{ - title: gui.c.Tr.StagedChanges, - task: NewRunPtyTask(cmdObj.GetCmd()), - context: mainContext, - } - } - } else { + if mainShowsStaged { refreshOpts.main.title = gui.c.Tr.StagedChanges } + 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, + } + } + return gui.refreshMainViews(refreshOpts) }