From 1ef585969fbbbf752af0db3a8ff688cda50a2f9f Mon Sep 17 00:00:00 2001 From: HiromasaNojima <67505578+HiromasaNojima@users.noreply.github.com> Date: Sun, 8 May 2022 17:24:55 +0900 Subject: [PATCH] add option to always show unstaged/staged panels --- docs/Config.md | 1 + pkg/config/user_config.go | 2 ++ pkg/gui/files_panel.go | 16 ++++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) 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..13d8e0470 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -67,7 +67,7 @@ func (gui *Gui) filesRenderToMain() error { }} if node.GetHasUnstagedChanges() { - if node.GetHasStagedChanges() { + if node.GetHasStagedChanges() || gui.c.UserConfig.Gui.SplitDiff == "always" { cmdObj := gui.git.WorkingTree.WorktreeFileDiffCmdObj(node, false, true, gui.IgnoreWhitespaceInDiffView) refreshOpts.secondary = &viewUpdateOpts{ @@ -77,7 +77,19 @@ func (gui *Gui) filesRenderToMain() error { } } } else { - refreshOpts.main.title = gui.c.Tr.StagedChanges + if gui.c.UserConfig.Gui.SplitDiff == "auto" { + refreshOpts.main.title = gui.c.Tr.StagedChanges + } else { + cmdObj := gui.git.WorkingTree.WorktreeFileDiffCmdObj(node, false, false, gui.IgnoreWhitespaceInDiffView) + refreshOpts.main.task = NewRunPtyTask(cmdObj.GetCmd()) + + 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)