summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-19 21:13:43 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-23 14:29:18 +1000
commitdbf6bb5f2792afc4adebc9087529de5ac433131c (patch)
treeb04dbc5e4d0d50099f5f3d39f5d1cc2fff1d41d4 /pkg/gui
parentf601108c5d66176ee671b2c8af2c29d0a58c3461 (diff)
some more things
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/commit_files_panel.go6
-rw-r--r--pkg/gui/context.go69
-rw-r--r--pkg/gui/tags_panel.go13
3 files changed, 38 insertions, 50 deletions
diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go
index a56f29dad..f5b69af6b 100644
--- a/pkg/gui/commit_files_panel.go
+++ b/pkg/gui/commit_files_panel.go
@@ -102,11 +102,7 @@ func (gui *Gui) refreshCommitFilesView() error {
}
gui.State.CommitFiles = files
- if err := gui.renderCommitFiles(); err != nil {
- return err
- }
-
- return gui.handleCommitFileSelect()
+ return gui.postRefreshUpdate(gui.Contexts.BranchCommits.Files.Context)
}
func (gui *Gui) renderCommitFiles() error {
diff --git a/pkg/gui/context.go b/pkg/gui/context.go
index cdfcc373f..9f66481c4 100644
--- a/pkg/gui/context.go
+++ b/pkg/gui/context.go
@@ -105,6 +105,7 @@ func (gui *Gui) allContexts() []Context {
gui.Contexts.Branches.Context,
gui.Contexts.Remotes.Context,
gui.Contexts.Remotes.Branches.Context,
+ gui.Contexts.Tags.Context,
gui.Contexts.BranchCommits.Context,
gui.Contexts.BranchCommits.Files.Context,
gui.Contexts.ReflogCommits.Context,
@@ -256,6 +257,40 @@ func (gui *Gui) initialViewContextMap() map[string]Context {
}
}
+func (gui *Gui) viewTabContextMap() map[string][]tabContext {
+ return map[string][]tabContext{
+ "branches": {
+ {
+ tab: "Local Branches",
+ contexts: []Context{gui.Contexts.Branches.Context},
+ },
+ {
+ tab: "Remotes",
+ contexts: []Context{
+ gui.Contexts.Remotes.Context,
+ gui.Contexts.Remotes.Branches.Context,
+ },
+ },
+ {
+ tab: "Tags",
+ contexts: []Context{gui.Contexts.Tags.Context},
+ },
+ },
+ "commits": {
+ {
+ tab: "Commits",
+ contexts: []Context{gui.Contexts.BranchCommits.Context},
+ },
+ {
+ tab: "Reflog",
+ contexts: []Context{
+ gui.Contexts.ReflogCommits.Context,
+ },
+ },
+ },
+ }
+}
+
func (gui *Gui) switchContext(c Context) error {
gui.g.Update(func(*gocui.Gui) error {
// push onto stack
@@ -501,40 +536,6 @@ func (gui *Gui) changeMainViewsContext(context string) {
gui.State.MainContext = context
}
-func (gui *Gui) viewTabContextMap() map[string][]tabContext {
- return map[string][]tabContext{
- "branches": {
- {
- tab: "Local Branches",
- contexts: []Context{gui.Contexts.Branches.Context},
- },
- {
- tab: "Remotes",
- contexts: []Context{
- gui.Contexts.Remotes.Context,
- gui.Contexts.Remotes.Branches.Context,
- },
- },
- {
- tab: "Tags",
- contexts: []Context{gui.Contexts.Tags.Context},
- },
- },
- "commits": {
- {
- tab: "Commits",
- contexts: []Context{gui.Contexts.BranchCommits.Context},
- },
- {
- tab: "Reflog",
- contexts: []Context{
- gui.Contexts.ReflogCommits.Context,
- },
- },
- },
- }
-}
-
func (gui *Gui) viewTabNames(viewName string) []string {
tabContexts := gui.ViewTabContextMap[viewName]
diff --git a/pkg/gui/tags_panel.go b/pkg/gui/tags_panel.go
index 9d151d4d8..2bb14b963 100644
--- a/pkg/gui/tags_panel.go
+++ b/pkg/gui/tags_panel.go
@@ -53,11 +53,7 @@ func (gui *Gui) refreshTags() error {
gui.State.Tags = tags
- if gui.getBranchesView().Context == "tags" {
- return gui.renderTagsContext()
- }
-
- return nil
+ return gui.postRefreshUpdate(gui.Contexts.Tags.Context)
}
func (gui *Gui) renderTagsContext() error {
@@ -66,11 +62,6 @@ func (gui *Gui) renderTagsContext() error {
gui.refreshSelectedLine(&gui.State.Panels.Tags.SelectedLine, len(gui.State.Tags))
displayStrings := presentation.GetTagListDisplayStrings(gui.State.Tags, gui.State.Diff.Ref)
gui.renderDisplayStrings(branchesView, displayStrings)
- if gui.g.CurrentView() == branchesView && branchesView.Context == "tags" {
- if err := gui.handleTagSelect(); err != nil {
- return gui.surfaceError(err)
- }
- }
return nil
}
@@ -145,7 +136,7 @@ func (gui *Gui) handleCreateTag(g *gocui.Gui, v *gocui.View) error {
for i, tag := range gui.State.Tags {
if tag.Name == tagName {
gui.State.Panels.Tags.SelectedLine = i
- gui.renderTagsContext()
+ _ = gui.renderTagsContext()
return
}
}