From 62a31c27e137bb79145fb92d8223b33ecd6d985e Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 26 Sep 2020 11:35:06 +1000 Subject: [PATCH] refresh commit files view when needed --- pkg/gui/commits_panel.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index bf2fc5360..541ab465e 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -85,8 +85,19 @@ func (gui *Gui) refreshCommits() error { go func() { _ = gui.refreshCommitsWithLimit() - if gui.g.CurrentView() == gui.getCommitFilesView() || (gui.currentContext().GetKey() == gui.Contexts.PatchBuilding.Context.GetKey()) { - _ = gui.refreshCommitFilesView() + context, ok := gui.Contexts.CommitFiles.Context.GetParentContext() + if ok && context.GetKey() == BRANCH_COMMITS_CONTEXT_KEY { + // This makes sense when we've e.g. just amended a commit, meaning we get a new commit SHA at the same position. + // However if we've just added a brand new commit, it pushes the list down by one and so we would end up + // showing the contents of a different commit than the one we initially entered. + // Ideally we would know when to refresh the commit files context and when not to, + // or perhaps we could just pop that context off the stack whenever cycling windows. + // For now the awkwardness remains. + commit := gui.getSelectedLocalCommit() + if commit != nil { + gui.State.Panels.CommitFiles.refName = commit.RefName() + _ = gui.refreshCommitFilesView() + } } wg.Done() }()