diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-05 13:07:44 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-06 19:34:32 +1000 |
commit | 7bc6dc5cf37486190b05f17e8abdd0827d4bd2f6 (patch) | |
tree | 4cc3bef71464465a1cc2b55e44da17fa1c40e316 | |
parent | ee7b634dced182e76ab83f9d025001f506e6b59e (diff) |
show branches context when starting in filtering mode
-rw-r--r-- | pkg/gui/gui.go | 14 | ||||
-rw-r--r-- | pkg/gui/modes/filtering/filtering.go | 4 |
2 files changed, 10 insertions, 8 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 0dfc8ecb1..f2e846660 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -54,9 +54,9 @@ type ContextManager struct { sync.Mutex } -func NewContextManager(contexts ContextTree) ContextManager { +func NewContextManager(initialContext Context) ContextManager { return ContextManager{ - ContextStack: []Context{contexts.Files}, + ContextStack: []Context{initialContext}, Mutex: sync.Mutex{}, } } @@ -366,13 +366,15 @@ func (gui *Gui) resetState(filterPath string) { showTree := gui.Config.GetUserConfig().Gui.ShowFileTree + contexts := gui.contextTree() + screenMode := SCREEN_NORMAL + initialContext := contexts.Files if filterPath != "" { screenMode = SCREEN_HALF + initialContext = contexts.BranchCommits } - contexts := gui.contextTree() - gui.State = &guiState{ FileManager: filetree.NewFileManager(make([]*models.File, 0), gui.Log, showTree), CommitFileManager: filetree.NewCommitFileManager(make([]*models.CommitFile, 0), gui.Log, showTree), @@ -406,7 +408,7 @@ func (gui *Gui) resetState(filterPath string) { SideView: nil, Ptmx: nil, Modes: Modes{ - Filtering: filtering.NewFiltering(), + Filtering: filtering.NewFiltering(filterPath), CherryPicking: CherryPicking{ CherryPickedCommits: make([]*models.Commit, 0), ContextKey: "", @@ -417,7 +419,7 @@ func (gui *Gui) resetState(filterPath string) { ViewTabContextMap: contexts.initialViewTabContextMap(), ScreenMode: screenMode, // TODO: put contexts in the context manager - ContextManager: NewContextManager(contexts), + ContextManager: NewContextManager(initialContext), Contexts: contexts, } diff --git a/pkg/gui/modes/filtering/filtering.go b/pkg/gui/modes/filtering/filtering.go index da6c97a90..010a04993 100644 --- a/pkg/gui/modes/filtering/filtering.go +++ b/pkg/gui/modes/filtering/filtering.go @@ -4,8 +4,8 @@ type Filtering struct { path string // the filename that gets passed to git log } -func NewFiltering() Filtering { - return Filtering{path: ""} +func NewFiltering(path string) Filtering { + return Filtering{path: path} } func (m *Filtering) Active() bool { |