mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-20 05:19:24 +02:00
allow toggling tree view for commit files panel
This commit is contained in:
parent
82fe4aa6c0
commit
8dee06f83a
@ -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
|
||||
}
|
||||
|
@ -850,20 +850,13 @@ func (gui *Gui) handleToggleDirCollapsed() error {
|
||||
|
||||
func (gui *Gui) handleToggleFileTreeView() error {
|
||||
// get path of currently selected file
|
||||
node := gui.getSelectedFileChangeNode()
|
||||
path := ""
|
||||
if node != nil {
|
||||
path = node.Path
|
||||
}
|
||||
path := gui.getSelectedPath()
|
||||
|
||||
gui.State.FileChangeManager.ToggleShowTree()
|
||||
|
||||
if path != "" {
|
||||
gui.State.FileChangeManager.ExpandToPath(path)
|
||||
}
|
||||
|
||||
// find that same node in the new format and move the cursor to it
|
||||
if path != "" {
|
||||
gui.State.FileChangeManager.ExpandToPath(path)
|
||||
index, found := gui.State.FileChangeManager.GetIndexForPath(path)
|
||||
if found {
|
||||
gui.filesListContext().GetPanelState().SetSelectedLineIdx(index)
|
||||
|
@ -910,12 +910,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
Handler: gui.wrappedHandler(gui.handleCopySelectedSideContextItemToClipboard),
|
||||
Description: gui.Tr.LcCopyCommitShaToClipboard,
|
||||
},
|
||||
{
|
||||
ViewName: "commitFiles",
|
||||
Key: gui.getKey(config.Universal.CopyToClipboard),
|
||||
Handler: gui.wrappedHandler(gui.handleCopySelectedSideContextItemToClipboard),
|
||||
Description: gui.Tr.LcCopyCommitFileNameToClipboard,
|
||||
},
|
||||
{
|
||||
ViewName: "branches",
|
||||
Contexts: []string{SUB_COMMITS_CONTEXT_KEY},
|
||||
@ -1039,6 +1033,12 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleInfoClick,
|
||||
},
|
||||
{
|
||||
ViewName: "commitFiles",
|
||||
Key: gui.getKey(config.Universal.CopyToClipboard),
|
||||
Handler: gui.wrappedHandler(gui.handleCopySelectedSideContextItemToClipboard),
|
||||
Description: gui.Tr.LcCopyCommitFileNameToClipboard,
|
||||
},
|
||||
{
|
||||
ViewName: "commitFiles",
|
||||
Key: gui.getKey(config.CommitFiles.CheckoutCommitFile),
|
||||
@ -1075,6 +1075,12 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
Handler: gui.handleEnterCommitFile,
|
||||
Description: gui.Tr.LcEnterFile,
|
||||
},
|
||||
{
|
||||
ViewName: "commitFiles",
|
||||
Key: gui.getKey(config.Files.ToggleTreeView),
|
||||
Handler: gui.wrappedHandler(gui.handleToggleCommitFileTreeView),
|
||||
Description: gui.Tr.LcToggleTreeView,
|
||||
},
|
||||
{
|
||||
ViewName: "",
|
||||
Key: gui.getKey(config.Universal.FilteringMenu),
|
||||
|
@ -237,13 +237,16 @@ func (gui *Gui) renderOptionsMap(optionsMap map[string]string) {
|
||||
gui.renderString("options", gui.optionsMapToString(optionsMap))
|
||||
}
|
||||
|
||||
// TODO: refactor properly
|
||||
// i'm so sorry but had to add this getBranchesView
|
||||
func (gui *Gui) getFilesView() *gocui.View {
|
||||
v, _ := gui.g.View("files")
|
||||
return v
|
||||
}
|
||||
|
||||
func (gui *Gui) getCommitFilesView() *gocui.View {
|
||||
v, _ := gui.g.View("commitFiles")
|
||||
return v
|
||||
}
|
||||
|
||||
func (gui *Gui) getCommitMessageView() *gocui.View {
|
||||
v, _ := gui.g.View("commitMessage")
|
||||
return v
|
||||
|
Loading…
x
Reference in New Issue
Block a user