summaryrefslogtreecommitdiffstats
path: root/pkg/gui/context/sub_commits_context.go
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-07-11 12:13:40 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-07-31 08:34:01 +0200
commit6dc25d796b0315764c4c50a590dde91c802ea5dc (patch)
treec64ffa1abeb0f99b1318166fd28c6bd24105c0be /pkg/gui/context/sub_commits_context.go
parent0c07963a2e76c54cbde14dc2da20450454f0e286 (diff)
Visualize local branch heads in commits panel
We want to mark all local branch heads with a "*" in the local commits panel, to make it easier to see how branches are stacked onto each other. In order to not confuse users with "*" markers that they don't understand, do this only for the case where users actually use stacked branches; those users are likely not going to be confused by the display. This means we want to filter out a few branch heads that shouldn't get the marker: the current branch, any main branch, and any old branch that has been merged to master already.
Diffstat (limited to 'pkg/gui/context/sub_commits_context.go')
-rw-r--r--pkg/gui/context/sub_commits_context.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/gui/context/sub_commits_context.go b/pkg/gui/context/sub_commits_context.go
index 0cf884589..1a606ac91 100644
--- a/pkg/gui/context/sub_commits_context.go
+++ b/pkg/gui/context/sub_commits_context.go
@@ -37,6 +37,13 @@ func NewSubCommitsContext(
}
getDisplayStrings := func(startIdx int, length int) [][]string {
+ // This can happen if a sub-commits view is asked to be rerendered while
+ // it is invisble; for example when switching screen modes, which
+ // rerenders all views.
+ if viewModel.GetRef() == nil {
+ return [][]string{}
+ }
+
selectedCommitSha := ""
if c.CurrentContext().GetKey() == SUB_COMMITS_CONTEXT_KEY {
selectedCommit := viewModel.GetSelected()
@@ -47,6 +54,8 @@ func NewSubCommitsContext(
return presentation.GetCommitListDisplayStrings(
c.Common,
c.Model().SubCommits,
+ c.Model().Branches,
+ viewModel.GetRef().RefName(),
c.State().GetRepoState().GetScreenMode() != types.SCREEN_NORMAL,
c.Modes().CherryPicking.SelectedShaSet(),
c.Modes().Diffing.Ref,