summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-19 19:13:47 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-23 14:29:18 +1000
commit7ebed76d16026348abf586ff19e534f7297d7fce (patch)
treecd6ddb2e6b5ec134db209b30c7e443028f9b9ade /pkg/gui
parent2b812b01e9d80409a0bf212eb7208dcdd6f5c974 (diff)
WIP
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/branches_panel.go22
-rw-r--r--pkg/gui/commits_panel.go18
-rw-r--r--pkg/gui/reflog_panel.go11
3 files changed, 7 insertions, 44 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index b82301aaa..59a1e9f8f 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -89,11 +89,6 @@ func (gui *Gui) renderLocalBranchesWithSelection() error {
gui.refreshSelectedLine(&gui.State.Panels.Branches.SelectedLine, len(gui.State.Branches))
displayStrings := presentation.GetBranchListDisplayStrings(gui.State.Branches, gui.State.ScreenMode != SCREEN_NORMAL, gui.State.Diff.Ref)
gui.renderDisplayStrings(branchesView, displayStrings)
- // if gui.g.CurrentView() == branchesView {
- // if err := gui.handleBranchSelect(); err != nil {
- // return gui.surfaceError(err)
- // }
- // }
return nil
}
@@ -453,23 +448,6 @@ func (gui *Gui) onBranchesTabClick(tabIndex int) error {
return gui.switchContext(context)
}
-func (gui *Gui) refreshBranchesViewWithSelection() error {
- branchesView := gui.getBranchesView()
-
- switch branchesView.Context {
- case "local-branches":
- return gui.renderLocalBranchesWithSelection()
- case "remotes":
- return gui.renderRemotesWithSelection()
- case "remote-branches":
- return gui.renderRemoteBranchesWithSelection()
- case "tags":
- return gui.renderTagsWithSelection()
- }
-
- return nil
-}
-
func (gui *Gui) handleNextBranchesTab(g *gocui.Gui, v *gocui.View) error {
return gui.onBranchesTabClick(
utils.ModuloWithWrap(v.TabIndex+1, len(v.Tabs)),
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index 6e5e2d201..1103b6867 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -119,13 +119,7 @@ func (gui *Gui) refreshCommitsWithLimit() error {
}
gui.State.Commits = commits
- if gui.getCommitsView().Context == "branch-commits" {
- if err := gui.renderBranchCommitsWithSelection(); err != nil {
- return err
- }
- }
-
- return nil
+ return gui.postRefreshUpdate(gui.Contexts.BranchCommits.Context)
}
// specific functions
@@ -439,12 +433,12 @@ func (gui *Gui) handleCopyCommit(g *gocui.Gui, v *gocui.View) error {
for index, cherryPickedCommit := range gui.State.CherryPickedCommits {
if commit.Sha == cherryPickedCommit.Sha {
gui.State.CherryPickedCommits = append(gui.State.CherryPickedCommits[0:index], gui.State.CherryPickedCommits[index+1:]...)
- return gui.renderBranchCommitsWithSelection()
+ return gui.Contexts.BranchCommits.Context.HandleRender()
}
}
gui.addCommitToCherryPickedCommits(gui.State.Panels.Commits.SelectedLine)
- return gui.renderBranchCommitsWithSelection()
+ return gui.Contexts.BranchCommits.Context.HandleRender()
}
func (gui *Gui) cherryPickedCommitShaMap() map[string]bool {
@@ -492,7 +486,7 @@ func (gui *Gui) handleCopyCommitRange(g *gocui.Gui, v *gocui.View) error {
gui.addCommitToCherryPickedCommits(index)
}
- return gui.renderBranchCommitsWithSelection()
+ return gui.Contexts.BranchCommits.Context.HandleRender()
}
// HandlePasteCommits begins a cherry-pick rebase with the commits the user has copied
@@ -678,7 +672,7 @@ func (gui *Gui) refreshCommitsViewWithSelection() error {
switch commitsView.Context {
case "branch-commits":
- return gui.renderBranchCommitsWithSelection()
+ return gui.Contexts.BranchCommits.Context.HandleRender()
case "reflog-commits":
return gui.renderReflogCommitsWithSelection()
}
@@ -721,7 +715,7 @@ func (gui *Gui) handleOpenSearchForCommitsPanel(g *gocui.Gui, v *gocui.View) err
func (gui *Gui) handleResetCherryPick(g *gocui.Gui, v *gocui.View) error {
gui.State.CherryPickedCommits = []*commands.Commit{}
- return gui.renderBranchCommitsWithSelection()
+ return gui.Contexts.BranchCommits.Context.HandleRender()
}
func (gui *Gui) handleGotoBottomForCommitsPanel(g *gocui.Gui, v *gocui.View) error {
diff --git a/pkg/gui/reflog_panel.go b/pkg/gui/reflog_panel.go
index 1fc7abbd0..03a1ed2be 100644
--- a/pkg/gui/reflog_panel.go
+++ b/pkg/gui/reflog_panel.go
@@ -85,11 +85,7 @@ func (gui *Gui) refreshReflogCommits() error {
state.FilteredReflogCommits = state.ReflogCommits
}
- if gui.getCommitsView().Context == "reflog-commits" {
- return gui.renderReflogCommitsWithSelection()
- }
-
- return nil
+ return gui.postRefreshUpdate(gui.Contexts.ReflogCommits.Context)
}
func (gui *Gui) renderReflogCommitsWithSelection() error {
@@ -98,11 +94,6 @@ func (gui *Gui) renderReflogCommitsWithSelection() error {
gui.refreshSelectedLine(&gui.State.Panels.ReflogCommits.SelectedLine, len(gui.State.FilteredReflogCommits))
displayStrings := presentation.GetReflogCommitListDisplayStrings(gui.State.FilteredReflogCommits, gui.State.ScreenMode != SCREEN_NORMAL, gui.State.Diff.Ref)
gui.renderDisplayStrings(commitsView, displayStrings)
- if gui.g.CurrentView() == commitsView && commitsView.Context == "reflog-commits" {
- if err := gui.handleReflogCommitSelect(); err != nil {
- return err
- }
- }
return nil
}