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

allow toggling tree view for commit files panel

This commit is contained in:
Jesse Duffield
2021-03-31 23:20:36 +11:00
parent 82fe4aa6c0
commit 8dee06f83a
4 changed files with 43 additions and 17 deletions

View File

@ -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
}