diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-27 19:12:15 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-28 11:59:45 +1100 |
commit | 198d237679bcc19655138f76a11770c3ef91ec4f (patch) | |
tree | ecc09e91f96baeaf75d437f5fbd00e007d4c6472 /pkg/gui/status_panel.go | |
parent | 39315ca1e2f526911ea35d9848b0427093e4080a (diff) |
more centralised handling of refreshing
Diffstat (limited to 'pkg/gui/status_panel.go')
-rw-r--r-- | pkg/gui/status_panel.go | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/pkg/gui/status_panel.go b/pkg/gui/status_panel.go index c6ebff794..6a952b580 100644 --- a/pkg/gui/status_panel.go +++ b/pkg/gui/status_panel.go @@ -12,6 +12,7 @@ import ( // never call this on its own, it should only be called from within refreshCommits() func (gui *Gui) refreshStatus() { + currentBranch := gui.currentBranch() status := "" @@ -26,8 +27,8 @@ func (gui *Gui) refreshStatus() { status = utils.ColoredString(fmt.Sprintf("ā%sā%s ", currentBranch.Pushables, currentBranch.Pullables), trackColor) } - if gui.State.WorkingTreeState != "normal" { - status += utils.ColoredString(fmt.Sprintf("(%s) ", gui.State.WorkingTreeState), color.FgYellow) + if gui.workingTreeState() != "normal" { + status += utils.ColoredString(fmt.Sprintf("(%s) ", gui.workingTreeState()), color.FgYellow) } name := utils.ColoredString(currentBranch.Name, presentation.GetBranchColor(currentBranch.Name)) @@ -59,10 +60,9 @@ func (gui *Gui) handleStatusClick(g *gocui.Gui, v *gocui.View) error { cx, _ := v.Cursor() upstreamStatus := fmt.Sprintf("ā%sā%s", currentBranch.Pushables, currentBranch.Pullables) repoName := utils.GetCurrentRepoName() - gui.Log.Warn(gui.State.WorkingTreeState) - switch gui.State.WorkingTreeState { + switch gui.workingTreeState() { case "rebasing", "merging": - workingTreeStatus := fmt.Sprintf("(%s)", gui.State.WorkingTreeState) + workingTreeStatus := fmt.Sprintf("(%s)", gui.workingTreeState()) if cursorInSubstring(cx, upstreamStatus+" ", workingTreeStatus) { return gui.handleCreateRebaseOptionsMenu(gui.g, v) } @@ -128,23 +128,14 @@ func lazygitTitle() string { |___/ |___/ ` } -func (gui *Gui) updateWorkTreeState() error { - rebaseMode, err := gui.GitCommand.RebaseMode() - if err != nil { - return err - } +func (gui *Gui) workingTreeState() string { + rebaseMode, _ := gui.GitCommand.RebaseMode() if rebaseMode != "" { - gui.State.WorkingTreeState = "rebasing" - return nil - } - merging, err := gui.GitCommand.IsInMergeState() - if err != nil { - return err + return "rebasing" } + merging, _ := gui.GitCommand.IsInMergeState() if merging { - gui.State.WorkingTreeState = "merging" - return nil + return "merging" } - gui.State.WorkingTreeState = "normal" - return nil + return "normal" } |