summaryrefslogtreecommitdiffstats
path: root/pkg/gui/commits_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-09-26 11:35:06 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-09-26 11:52:38 +1000
commit62a31c27e137bb79145fb92d8223b33ecd6d985e (patch)
tree83011354d5301baae710d23fa4bdb61d19bc657c /pkg/gui/commits_panel.go
parentdd29ee72886c34f807e8e22b87dfa5dd2d9251bd (diff)
refresh commit files view when needed
Diffstat (limited to 'pkg/gui/commits_panel.go')
-rw-r--r--pkg/gui/commits_panel.go15
1 files 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()
}()