mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-15 01:34:26 +02:00
refactor
This commit is contained in:
@ -53,42 +53,31 @@ func (gui *Gui) filesRenderToMain() error {
|
|||||||
|
|
||||||
gui.resetMergeStateWithLock()
|
gui.resetMergeStateWithLock()
|
||||||
|
|
||||||
cmdObj := gui.git.WorkingTree.WorktreeFileDiffCmdObj(node, false, !node.GetHasUnstagedChanges() && node.GetHasStagedChanges(), gui.IgnoreWhitespaceInDiffView)
|
|
||||||
|
|
||||||
mainContext := gui.State.Contexts.Normal
|
mainContext := gui.State.Contexts.Normal
|
||||||
if node.File != nil {
|
if node.File != nil {
|
||||||
mainContext = gui.State.Contexts.Staging
|
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{
|
refreshOpts := refreshMainOpts{main: &viewUpdateOpts{
|
||||||
title: gui.c.Tr.UnstagedChanges,
|
title: gui.c.Tr.UnstagedChanges,
|
||||||
task: NewRunPtyTask(cmdObj.GetCmd()),
|
task: NewRunPtyTask(cmdObj.GetCmd()),
|
||||||
context: mainContext,
|
context: mainContext,
|
||||||
}}
|
}}
|
||||||
|
if mainShowsStaged {
|
||||||
|
refreshOpts.main.title = gui.c.Tr.StagedChanges
|
||||||
|
}
|
||||||
|
|
||||||
if node.GetHasUnstagedChanges() {
|
if split {
|
||||||
if node.GetHasStagedChanges() || gui.c.UserConfig.Gui.SplitDiff == "always" {
|
cmdObj := gui.git.WorkingTree.WorktreeFileDiffCmdObj(node, false, true, gui.IgnoreWhitespaceInDiffView)
|
||||||
cmdObj := gui.git.WorkingTree.WorktreeFileDiffCmdObj(node, false, true, gui.IgnoreWhitespaceInDiffView)
|
|
||||||
|
|
||||||
refreshOpts.secondary = &viewUpdateOpts{
|
refreshOpts.secondary = &viewUpdateOpts{
|
||||||
title: gui.c.Tr.StagedChanges,
|
title: gui.c.Tr.StagedChanges,
|
||||||
task: NewRunPtyTask(cmdObj.GetCmd()),
|
task: NewRunPtyTask(cmdObj.GetCmd()),
|
||||||
context: mainContext,
|
context: mainContext,
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
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,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user