diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-03-31 23:20:36 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-02 11:00:15 +1100 |
commit | 8dee06f83a1aebe9eb085e67b790f166f9d205af (patch) | |
tree | 620c8ef558e6d38d82c2565ca854c0b22d1e6f0f /pkg/gui/commit_files_panel.go | |
parent | 82fe4aa6c0e24852f4c73030447fdd99deda5e66 (diff) |
allow toggling tree view for commit files panel
Diffstat (limited to 'pkg/gui/commit_files_panel.go')
-rw-r--r-- | pkg/gui/commit_files_panel.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go index d0c0228ec..aa95b0862 100644 --- a/pkg/gui/commit_files_panel.go +++ b/pkg/gui/commit_files_panel.go @@ -275,3 +275,27 @@ func (gui *Gui) switchToCommitFilesContext(refName string, canRebase bool, conte return gui.pushContext(gui.Contexts.CommitFiles.Context) } + +// NOTE: this is very similar to handleToggleFileTreeView, could be DRY'd with generics +func (gui *Gui) handleToggleCommitFileTreeView() error { + path := gui.getSelectedCommitFilePath() + + gui.State.CommitFileChangeManager.ToggleShowTree() + + // find that same node in the new format and move the cursor to it + if path != "" { + gui.State.CommitFileChangeManager.ExpandToPath(path) + index, found := gui.State.CommitFileChangeManager.GetIndexForPath(path) + if found { + gui.commitFilesListContext().GetPanelState().SetSelectedLineIdx(index) + } + } + + if gui.getCommitFilesView().Context == COMMIT_FILES_CONTEXT_KEY { + if err := gui.Contexts.CommitFiles.Context.HandleRender(); err != nil { + return err + } + } + + return nil +} |