summaryrefslogtreecommitdiffstats
path: root/pkg/gui/branches_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-18 09:03:52 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-23 14:29:18 +1000
commit3c87ff4eff46449d5e697e954b3bdf01d2c76f19 (patch)
treec1c8c67ba187d1d145e803a99957093682e3145b /pkg/gui/branches_panel.go
parent0f7b2c45d773989229cb84a0147232962c6ae0e0 (diff)
WIP: standardising how we render to main
Diffstat (limited to 'pkg/gui/branches_panel.go')
-rw-r--r--pkg/gui/branches_panel.go39
1 files changed, 24 insertions, 15 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index 1cb1ba5fa..b856b4007 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -13,6 +13,10 @@ import (
// list panel functions
func (gui *Gui) getSelectedBranch() *commands.Branch {
+ if len(gui.State.Branches) == 0 {
+ return nil
+ }
+
selectedLine := gui.State.Panels.Branches.SelectedLine
if selectedLine == -1 {
return nil
@@ -26,27 +30,32 @@ func (gui *Gui) handleBranchSelect() error {
return nil
}
- gui.splitMainPanel(false)
-
- gui.getMainView().Title = "Log"
+ if gui.inDiffMode() {
+ return gui.renderDiff()
+ }
- // This really shouldn't happen: there should always be a master branch
- if len(gui.State.Branches) == 0 {
- return gui.newStringTask("main", gui.Tr.SLocalize("NoBranchesThisRepo"))
+ refreshOpts := refreshMainOpts{
+ main: &viewUpdateOpts{
+ title: "Log",
+ task: {
+ kind: RENDER_STRING,
+ str: gui.Tr.SLocalize("NoBranchesThisRepo"),
+ },
+ },
}
+
branch := gui.getSelectedBranch()
+ if branch == nil {
+ refreshOpts.main.task = func() error { return gui.newStringTask("main", gui.Tr.SLocalize("NoBranchesThisRepo")) }
+ } else {
+ cmd := gui.OSCommand.ExecutableFromString(
+ gui.GitCommand.GetBranchGraphCmdStr(branch.Name),
+ )
- if gui.inDiffMode() {
- return gui.renderDiff()
+ refreshOpts.main.task = func() error { return gui.newPtyTask("main", cmd) }
}
- cmd := gui.OSCommand.ExecutableFromString(
- gui.GitCommand.GetBranchGraphCmdStr(branch.Name),
- )
- if err := gui.newCmdTask("main", cmd); err != nil {
- gui.Log.Error(err)
- }
- return nil
+ return gui.refreshMain(refreshOpts)
}
// gui.refreshStatus is called at the end of this because that's when we can