1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-08 23:56:15 +02:00

show branches context when starting in filtering mode

This commit is contained in:
Jesse Duffield 2021-04-05 13:07:44 +10:00
parent ee7b634dce
commit 7bc6dc5cf3
2 changed files with 10 additions and 8 deletions

View File

@ -54,9 +54,9 @@ type ContextManager struct {
sync.Mutex sync.Mutex
} }
func NewContextManager(contexts ContextTree) ContextManager { func NewContextManager(initialContext Context) ContextManager {
return ContextManager{ return ContextManager{
ContextStack: []Context{contexts.Files}, ContextStack: []Context{initialContext},
Mutex: sync.Mutex{}, Mutex: sync.Mutex{},
} }
} }
@ -366,13 +366,15 @@ func (gui *Gui) resetState(filterPath string) {
showTree := gui.Config.GetUserConfig().Gui.ShowFileTree showTree := gui.Config.GetUserConfig().Gui.ShowFileTree
contexts := gui.contextTree()
screenMode := SCREEN_NORMAL screenMode := SCREEN_NORMAL
initialContext := contexts.Files
if filterPath != "" { if filterPath != "" {
screenMode = SCREEN_HALF screenMode = SCREEN_HALF
initialContext = contexts.BranchCommits
} }
contexts := gui.contextTree()
gui.State = &guiState{ gui.State = &guiState{
FileManager: filetree.NewFileManager(make([]*models.File, 0), gui.Log, showTree), FileManager: filetree.NewFileManager(make([]*models.File, 0), gui.Log, showTree),
CommitFileManager: filetree.NewCommitFileManager(make([]*models.CommitFile, 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, SideView: nil,
Ptmx: nil, Ptmx: nil,
Modes: Modes{ Modes: Modes{
Filtering: filtering.NewFiltering(), Filtering: filtering.NewFiltering(filterPath),
CherryPicking: CherryPicking{ CherryPicking: CherryPicking{
CherryPickedCommits: make([]*models.Commit, 0), CherryPickedCommits: make([]*models.Commit, 0),
ContextKey: "", ContextKey: "",
@ -417,7 +419,7 @@ func (gui *Gui) resetState(filterPath string) {
ViewTabContextMap: contexts.initialViewTabContextMap(), ViewTabContextMap: contexts.initialViewTabContextMap(),
ScreenMode: screenMode, ScreenMode: screenMode,
// TODO: put contexts in the context manager // TODO: put contexts in the context manager
ContextManager: NewContextManager(contexts), ContextManager: NewContextManager(initialContext),
Contexts: contexts, Contexts: contexts,
} }

View File

@ -4,8 +4,8 @@ type Filtering struct {
path string // the filename that gets passed to git log path string // the filename that gets passed to git log
} }
func NewFiltering() Filtering { func NewFiltering(path string) Filtering {
return Filtering{path: ""} return Filtering{path: path}
} }
func (m *Filtering) Active() bool { func (m *Filtering) Active() bool {