@@ -10,7 +10,7 @@ import (
1010
1111func (gui * Gui ) getSelectedReflogCommit () * commands.Commit {
1212 selectedLine := gui .State .Panels .ReflogCommits .SelectedLine
13- reflogComits := gui .State .ReflogCommits
13+ reflogComits := gui .State .FilteredReflogCommits
1414 if selectedLine == - 1 || len (reflogComits ) == 0 {
1515 return nil
1616 }
@@ -51,6 +51,9 @@ func (gui *Gui) handleReflogCommitSelect(g *gocui.Gui, v *gocui.View) error {
5151// load entries that have been created since we last ran the call. This means
5252// we need to be more careful with how we use this, and to ensure we're emptying
5353// the reflogs array when changing contexts.
54+ // This method also manages two things: ReflogCommits and FilteredReflogCommits.
55+ // FilteredReflogCommits are rendered in the reflogs panel, and ReflogCommits
56+ // are used by the branches panel to obtain recency values for sorting.
5457func (gui * Gui ) refreshReflogCommits () error {
5558 // pulling state into its own variable incase it gets swapped out for another state
5659 // and we get an out of bounds exception
@@ -60,17 +63,30 @@ func (gui *Gui) refreshReflogCommits() error {
6063 lastReflogCommit = state .ReflogCommits [0 ]
6164 }
6265
63- commits , onlyObtainedNewReflogCommits , err := gui .GitCommand .GetReflogCommits (lastReflogCommit , state .FilterPath )
64- if err != nil {
65- return gui .surfaceError (err )
66+ refresh := func (stateCommits * []* commands.Commit , filterPath string ) error {
67+ commits , onlyObtainedNewReflogCommits , err := gui .GitCommand .GetReflogCommits (lastReflogCommit , filterPath )
68+ if err != nil {
69+ return gui .surfaceError (err )
70+ }
71+
72+ if onlyObtainedNewReflogCommits {
73+ * stateCommits = append (commits , * stateCommits ... )
74+ } else {
75+ * stateCommits = commits
76+ }
77+ return nil
6678 }
6779
68- if onlyObtainedNewReflogCommits {
69- state .ReflogCommits = append (commits , state .ReflogCommits ... )
80+ if err := refresh (& state .ReflogCommits , "" ); err != nil {
81+ return err
82+ }
83+
84+ if gui .inFilterMode () {
85+ if err := refresh (& state .FilteredReflogCommits , state .FilterPath ); err != nil {
86+ return err
87+ }
7088 } else {
71- // if we haven't found it we're probably in a new repo so we don't want to
72- // retain the old reflog commits
73- state .ReflogCommits = commits
89+ state .FilteredReflogCommits = state .ReflogCommits
7490 }
7591
7692 if gui .getCommitsView ().Context == "reflog-commits" {
@@ -83,8 +99,8 @@ func (gui *Gui) refreshReflogCommits() error {
8399func (gui * Gui ) renderReflogCommitsWithSelection () error {
84100 commitsView := gui .getCommitsView ()
85101
86- gui .refreshSelectedLine (& gui .State .Panels .ReflogCommits .SelectedLine , len (gui .State .ReflogCommits ))
87- displayStrings := presentation .GetReflogCommitListDisplayStrings (gui .State .ReflogCommits , gui .State .ScreenMode != SCREEN_NORMAL )
102+ gui .refreshSelectedLine (& gui .State .Panels .ReflogCommits .SelectedLine , len (gui .State .FilteredReflogCommits ))
103+ displayStrings := presentation .GetReflogCommitListDisplayStrings (gui .State .FilteredReflogCommits , gui .State .ScreenMode != SCREEN_NORMAL )
88104 gui .renderDisplayStrings (commitsView , displayStrings )
89105 if gui .g .CurrentView () == commitsView && commitsView .Context == "reflog-commits" {
90106 if err := gui .handleReflogCommitSelect (gui .g , commitsView ); err != nil {
0 commit comments