diff options
Diffstat (limited to 'pkg/gui/files_panel.go')
-rw-r--r-- | pkg/gui/files_panel.go | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 28c9667da..d443a7a8f 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -182,11 +182,17 @@ func (gui *Gui) handleEnterFile(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) enterFile(forceSecondaryFocused bool, selectedLineIdx int) error { - file := gui.getSelectedFile() - if file == nil { + node := gui.getSelectedStatusNode() + if node == nil { return nil } + if node.File == nil { + return gui.handleToggleDirCollapsed() + } + + file := node.File + submoduleConfigs := gui.State.Submodules if file.IsSubmodule(submoduleConfigs) { submoduleConfig := file.SubmoduleConfig(submoduleConfigs) @@ -742,3 +748,18 @@ func (gui *Gui) handleStashChanges(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) handleCreateResetToUpstreamMenu(g *gocui.Gui, v *gocui.View) error { return gui.createResetMenu("@{upstream}") } + +func (gui *Gui) handleToggleDirCollapsed() error { + node := gui.getSelectedStatusNode() + if node == nil { + return nil + } + + gui.State.StatusLineManager.ToggleCollapsed(node) + + if err := gui.postRefreshUpdate(gui.Contexts.Files.Context); err != nil { + gui.Log.Error(err) + } + + return nil +} |