diff --git a/pkg/gui/controllers/remote_branches_controller.go b/pkg/gui/controllers/remote_branches_controller.go index c1cc9d46b..b26230d90 100644 --- a/pkg/gui/controllers/remote_branches_controller.go +++ b/pkg/gui/controllers/remote_branches_controller.go @@ -59,11 +59,6 @@ func (self *RemoteBranchesController) GetKeybindings(opts types.KeybindingsOpts) Handler: self.checkSelected(self.setAsUpstream), Description: self.c.Tr.SetAsUpstream, }, - { - Key: opts.GetKey(opts.Config.Universal.Return), - Handler: self.escape, - Description: self.c.Tr.ReturnToRemotesList, - }, { Key: opts.GetKey(opts.Config.Commits.ViewResetOptions), Handler: self.checkSelected(self.createResetMenu), @@ -115,10 +110,6 @@ func (self *RemoteBranchesController) checkSelected(callback func(*models.Remote } } -func (self *RemoteBranchesController) escape() error { - return self.c.PushContext(self.c.Contexts().Remotes) -} - func (self *RemoteBranchesController) delete(selectedBranch *models.RemoteBranch) error { message := fmt.Sprintf("%s '%s'?", self.c.Tr.DeleteRemoteBranchMessage, selectedBranch.FullName()) diff --git a/pkg/gui/controllers/remotes_controller.go b/pkg/gui/controllers/remotes_controller.go index 283119886..b6d9a963b 100644 --- a/pkg/gui/controllers/remotes_controller.go +++ b/pkg/gui/controllers/remotes_controller.go @@ -104,14 +104,16 @@ func (self *RemotesController) enter(remote *models.Remote) error { if len(remote.Branches) == 0 { newSelectedLine = -1 } - self.c.Contexts().RemoteBranches.SetSelectedLineIdx(newSelectedLine) - self.c.Contexts().RemoteBranches.SetTitleRef(remote.Name) + remoteBranchesContext := self.c.Contexts().RemoteBranches + remoteBranchesContext.SetSelectedLineIdx(newSelectedLine) + remoteBranchesContext.SetTitleRef(remote.Name) + remoteBranchesContext.SetParentContext(self.Context()) - if err := self.c.PostRefreshUpdate(self.c.Contexts().RemoteBranches); err != nil { + if err := self.c.PostRefreshUpdate(remoteBranchesContext); err != nil { return err } - return self.c.PushContext(self.c.Contexts().RemoteBranches) + return self.c.PushContext(remoteBranchesContext) } func (self *RemotesController) add() error { diff --git a/pkg/integration/tests/filter_and_search/filter_remote_branches.go b/pkg/integration/tests/filter_and_search/filter_remote_branches.go new file mode 100644 index 000000000..11cfea30b --- /dev/null +++ b/pkg/integration/tests/filter_and_search/filter_remote_branches.go @@ -0,0 +1,59 @@ +package filter_and_search + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var FilterRemoteBranches = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Filtering remote branches", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.NewBranch("branch-apple") + shell.EmptyCommit("commit-one") + shell.NewBranch("branch-grape") + shell.NewBranch("branch-orange") + + shell.CloneIntoRemote("origin") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Remotes(). + Focus(). + Lines( + Contains(`origin`).IsSelected(), + ). + PressEnter() + + t.Views().RemoteBranches(). + IsFocused(). + Lines( + Contains(`branch-apple`).IsSelected(), + Contains(`branch-grape`), + Contains(`branch-orange`), + ). + FilterOrSearch("grape"). + Lines( + Contains(`branch-grape`).IsSelected(), + ). + // cancel the filter + PressEscape(). + Tap(func() { + t.Views().Search().IsInvisible() + }). + Lines( + Contains(`branch-apple`), + Contains(`branch-grape`).IsSelected(), + Contains(`branch-orange`), + ). + // return to remotes view + PressEscape() + + t.Views().Remotes(). + IsFocused(). + Lines( + Contains(`origin`).IsSelected(), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index e3a6e51dd..9aab7ea43 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -98,6 +98,7 @@ var tests = []*components.IntegrationTest{ filter_and_search.FilterCommitFiles, filter_and_search.FilterFiles, filter_and_search.FilterMenu, + filter_and_search.FilterRemoteBranches, filter_and_search.NestedFilter, filter_and_search.NestedFilterTransient, filter_by_path.CliArg,