diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-21 19:53:45 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-23 14:29:18 +1000 |
commit | 2d90e1e8ee5ccb3d2acd8678e68137645c9e65bd (patch) | |
tree | cb623a51873bd086967ea794b21210861ce5031e /pkg/gui/commit_files_panel.go | |
parent | ddf25e14afe5ddfc2527149c54ea55ea2e83610a (diff) |
commit files kind of generalised
Diffstat (limited to 'pkg/gui/commit_files_panel.go')
-rw-r--r-- | pkg/gui/commit_files_panel.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go index e70092891..9854cfc77 100644 --- a/pkg/gui/commit_files_panel.go +++ b/pkg/gui/commit_files_panel.go @@ -1,6 +1,7 @@ package gui import ( + "github.com/davecgh/go-spew/spew" "github.com/go-errors/errors" "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands" @@ -80,12 +81,14 @@ func (gui *Gui) refreshCommitFilesView() error { return err } - files, err := gui.GitCommand.GetCommitFiles(gui.State.Panels.CommitFiles.refName, gui.GitCommand.PatchManager) + files, err := gui.GitCommand.GetFilesInRef(gui.State.Panels.CommitFiles.refName, gui.State.Panels.CommitFiles.isStash, gui.GitCommand.PatchManager) if err != nil { return gui.surfaceError(err) } gui.State.CommitFiles = files + gui.Log.Warn(spew.Sdump(files)) + return gui.postRefreshUpdate(gui.Contexts.CommitFiles.Context) } @@ -211,3 +214,23 @@ func (gui *Gui) enterCommitFile(selectedLineIdx int) error { return enterTheFile(selectedLineIdx) } + +func (gui *Gui) switchToCommitFilesContext(refName string, isStash bool, context Context, windowName string) error { + // sometimes the commitFiles view is already shown in another window, so we need to ensure that window + // no longer considers the commitFiles view as its main view. + + window := gui.getWindowForViewName("commitFiles") + gui.State.WindowViewNameMap[window] = window + + gui.State.Panels.CommitFiles.SelectedLineIdx = 0 + gui.State.Panels.CommitFiles.refName = refName + gui.State.Panels.CommitFiles.isStash = isStash + gui.Contexts.CommitFiles.Context.SetParentContext(context) + gui.Contexts.CommitFiles.Context.SetWindowName(windowName) + + if err := gui.refreshCommitFilesView(); err != nil { + return err + } + + return gui.switchContext(gui.Contexts.CommitFiles.Context) +} |