mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
allow toggling tree view for commit files panel
This commit is contained in:
@ -275,3 +275,27 @@ func (gui *Gui) switchToCommitFilesContext(refName string, canRebase bool, conte
|
|||||||
|
|
||||||
return gui.pushContext(gui.Contexts.CommitFiles.Context)
|
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 {
|
func (gui *Gui) handleToggleFileTreeView() error {
|
||||||
// get path of currently selected file
|
// get path of currently selected file
|
||||||
node := gui.getSelectedFileChangeNode()
|
path := gui.getSelectedPath()
|
||||||
path := ""
|
|
||||||
if node != nil {
|
|
||||||
path = node.Path
|
|
||||||
}
|
|
||||||
|
|
||||||
gui.State.FileChangeManager.ToggleShowTree()
|
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
|
// find that same node in the new format and move the cursor to it
|
||||||
if path != "" {
|
if path != "" {
|
||||||
|
gui.State.FileChangeManager.ExpandToPath(path)
|
||||||
index, found := gui.State.FileChangeManager.GetIndexForPath(path)
|
index, found := gui.State.FileChangeManager.GetIndexForPath(path)
|
||||||
if found {
|
if found {
|
||||||
gui.filesListContext().GetPanelState().SetSelectedLineIdx(index)
|
gui.filesListContext().GetPanelState().SetSelectedLineIdx(index)
|
||||||
|
@ -910,12 +910,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||||||
Handler: gui.wrappedHandler(gui.handleCopySelectedSideContextItemToClipboard),
|
Handler: gui.wrappedHandler(gui.handleCopySelectedSideContextItemToClipboard),
|
||||||
Description: gui.Tr.LcCopyCommitShaToClipboard,
|
Description: gui.Tr.LcCopyCommitShaToClipboard,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
ViewName: "commitFiles",
|
|
||||||
Key: gui.getKey(config.Universal.CopyToClipboard),
|
|
||||||
Handler: gui.wrappedHandler(gui.handleCopySelectedSideContextItemToClipboard),
|
|
||||||
Description: gui.Tr.LcCopyCommitFileNameToClipboard,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
ViewName: "branches",
|
ViewName: "branches",
|
||||||
Contexts: []string{SUB_COMMITS_CONTEXT_KEY},
|
Contexts: []string{SUB_COMMITS_CONTEXT_KEY},
|
||||||
@ -1039,6 +1033,12 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: gui.handleInfoClick,
|
Handler: gui.handleInfoClick,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ViewName: "commitFiles",
|
||||||
|
Key: gui.getKey(config.Universal.CopyToClipboard),
|
||||||
|
Handler: gui.wrappedHandler(gui.handleCopySelectedSideContextItemToClipboard),
|
||||||
|
Description: gui.Tr.LcCopyCommitFileNameToClipboard,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ViewName: "commitFiles",
|
ViewName: "commitFiles",
|
||||||
Key: gui.getKey(config.CommitFiles.CheckoutCommitFile),
|
Key: gui.getKey(config.CommitFiles.CheckoutCommitFile),
|
||||||
@ -1075,6 +1075,12 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||||||
Handler: gui.handleEnterCommitFile,
|
Handler: gui.handleEnterCommitFile,
|
||||||
Description: gui.Tr.LcEnterFile,
|
Description: gui.Tr.LcEnterFile,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ViewName: "commitFiles",
|
||||||
|
Key: gui.getKey(config.Files.ToggleTreeView),
|
||||||
|
Handler: gui.wrappedHandler(gui.handleToggleCommitFileTreeView),
|
||||||
|
Description: gui.Tr.LcToggleTreeView,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ViewName: "",
|
ViewName: "",
|
||||||
Key: gui.getKey(config.Universal.FilteringMenu),
|
Key: gui.getKey(config.Universal.FilteringMenu),
|
||||||
|
@ -237,13 +237,16 @@ func (gui *Gui) renderOptionsMap(optionsMap map[string]string) {
|
|||||||
gui.renderString("options", gui.optionsMapToString(optionsMap))
|
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 {
|
func (gui *Gui) getFilesView() *gocui.View {
|
||||||
v, _ := gui.g.View("files")
|
v, _ := gui.g.View("files")
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) getCommitFilesView() *gocui.View {
|
||||||
|
v, _ := gui.g.View("commitFiles")
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) getCommitMessageView() *gocui.View {
|
func (gui *Gui) getCommitMessageView() *gocui.View {
|
||||||
v, _ := gui.g.View("commitMessage")
|
v, _ := gui.g.View("commitMessage")
|
||||||
return v
|
return v
|
||||||
|
Reference in New Issue
Block a user