diff options
Diffstat (limited to 'pkg/gui/controllers')
-rw-r--r-- | pkg/gui/controllers/files_controller.go | 4 | ||||
-rw-r--r-- | pkg/gui/controllers/filter_controller.go | 48 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/confirmation_helper.go | 4 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/helpers.go | 2 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/refresh_helper.go | 4 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/search_helper.go | 260 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/window_arrangement_helper.go | 12 | ||||
-rw-r--r-- | pkg/gui/controllers/list_controller.go | 13 | ||||
-rw-r--r-- | pkg/gui/controllers/local_commits_controller.go | 4 | ||||
-rw-r--r-- | pkg/gui/controllers/patch_explorer_controller.go | 6 | ||||
-rw-r--r-- | pkg/gui/controllers/quit_actions.go | 13 | ||||
-rw-r--r-- | pkg/gui/controllers/remote_branches_controller.go | 9 | ||||
-rw-r--r-- | pkg/gui/controllers/remotes_controller.go | 10 | ||||
-rw-r--r-- | pkg/gui/controllers/search_controller.go | 48 | ||||
-rw-r--r-- | pkg/gui/controllers/search_prompt_controller.go | 53 | ||||
-rw-r--r-- | pkg/gui/controllers/switch_to_diff_files_controller.go | 1 | ||||
-rw-r--r-- | pkg/gui/controllers/switch_to_sub_commits_controller.go | 15 |
17 files changed, 458 insertions, 48 deletions
diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index 11d39ee9f..61d91ad69 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -648,7 +648,7 @@ func (self *FilesController) handleStatusFilterPressed() error { }, }, { - Label: self.c.Tr.ResetCommitFilterState, + Label: self.c.Tr.ResetFilter, OnPress: func() error { return self.setStatusFiltering(filetree.DisplayAll) }, @@ -658,7 +658,7 @@ func (self *FilesController) handleStatusFilterPressed() error { } func (self *FilesController) setStatusFiltering(filter filetree.FileTreeDisplayFilter) error { - self.context().FileTreeViewModel.SetFilter(filter) + self.context().FileTreeViewModel.SetStatusFilter(filter) return self.c.PostRefreshUpdate(self.context()) } diff --git a/pkg/gui/controllers/filter_controller.go b/pkg/gui/controllers/filter_controller.go new file mode 100644 index 000000000..8b049b26c --- /dev/null +++ b/pkg/gui/controllers/filter_controller.go @@ -0,0 +1,48 @@ +package controllers + +import ( + "github.com/jesseduffield/lazygit/pkg/gui/types" +) + +type FilterControllerFactory struct { + c *ControllerCommon +} + +func NewFilterControllerFactory(c *ControllerCommon) *FilterControllerFactory { + return &FilterControllerFactory{ + c: c, + } +} + +func (self *FilterControllerFactory) Create(context types.IFilterableContext) *FilterController { + return &FilterController{ + baseController: baseController{}, + c: self.c, + context: context, + } +} + +type FilterController struct { + baseController + c *ControllerCommon + + context types.IFilterableContext +} + +func (self *FilterController) Context() types.Context { + return self.context +} + +func (self *FilterController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding { + return []*types.Binding{ + { + Key: opts.GetKey(opts.Config.Universal.StartSearch), + Handler: self.OpenFilterPrompt, + Description: self.c.Tr.StartFilter, + }, + } +} + +func (self *FilterController) OpenFilterPrompt() error { + return self.c.Helpers().Search.OpenFilterPrompt(self.context) +} diff --git a/pkg/gui/controllers/helpers/confirmation_helper.go b/pkg/gui/controllers/helpers/confirmation_helper.go index 7968933fc..c721310b2 100644 --- a/pkg/gui/controllers/helpers/confirmation_helper.go +++ b/pkg/gui/controllers/helpers/confirmation_helper.go @@ -292,7 +292,9 @@ func (self *ConfirmationHelper) ResizePopupPanel(v *gocui.View, content string) } func (self *ConfirmationHelper) resizeMenu() { - itemCount := self.c.Contexts().Menu.GetList().Len() + // we want the unfiltered length here so that if we're filtering we don't + // resize the window + itemCount := self.c.Contexts().Menu.UnfilteredLen() offset := 3 panelWidth := self.getPopupPanelWidth() x0, y0, x1, y1 := self.getPopupPanelDimensionsForContentHeight(panelWidth, itemCount+offset) diff --git a/pkg/gui/controllers/helpers/helpers.go b/pkg/gui/controllers/helpers/helpers.go index faf342f0a..846638249 100644 --- a/pkg/gui/controllers/helpers/helpers.go +++ b/pkg/gui/controllers/helpers/helpers.go @@ -46,6 +46,7 @@ type Helpers struct { Mode *ModeHelper AppStatus *AppStatusHelper WindowArrangement *WindowArrangementHelper + Search *SearchHelper } func NewStubHelpers() *Helpers { @@ -78,5 +79,6 @@ func NewStubHelpers() *Helpers { Mode: &ModeHelper{}, AppStatus: &AppStatusHelper{}, WindowArrangement: &WindowArrangementHelper{}, + Search: &SearchHelper{}, } } diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index 7b37585a5..f0827dc41 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -464,10 +464,10 @@ func (self *RefreshHelper) refreshStateFiles() error { // I'd prefer to maintain as little state as possible. if conflictFileCount > 0 { if fileTreeViewModel.GetFilter() == filetree.DisplayAll { - fileTreeViewModel.SetFilter(filetree.DisplayConflicted) + fileTreeViewModel.SetStatusFilter(filetree.DisplayConflicted) } } else if fileTreeViewModel.GetFilter() == filetree.DisplayConflicted { - fileTreeViewModel.SetFilter(filetree.DisplayAll) + fileTreeViewModel.SetStatusFilter(filetree.DisplayAll) } self.c.Model().Files = files diff --git a/pkg/gui/controllers/helpers/search_helper.go b/pkg/gui/controllers/helpers/search_helper.go new file mode 100644 index 000000000..b244f20e4 --- /dev/null +++ b/pkg/gui/controllers/helpers/search_helper.go @@ -0,0 +1,260 @@ +package helpers + +import ( + "fmt" + + "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gui/context" + "github.com/jesseduffield/lazygit/pkg/gui/keybindings" + "github.com/jesseduffield/lazygit/pkg/gui/types" + "github.com/jesseduffield/lazygit/pkg/theme" +) + +// NOTE: this helper supports both filtering and searching. Filtering is when +// the contents of the list are filtered, whereas searching does not actually +// change the contents of the list but instead just highlights the search. +// The general term we use to capture both searching and filtering is... +// 'searching', which is unfortunate but I can't think of a better name. + +type SearchHelper struct { + c *HelperCommon +} + +func NewSearchHelper( + c *HelperCommon, +) *SearchHelper { + return &SearchHelper{ + c: c, + } +} + +func (self *SearchHelper) OpenFilterPrompt(context types.IFilterableContext) error { + state := self.searchState() + + state.Context = context + + self.searchPrefixView().SetContent(self.c.Tr.FilterPrefix) + promptView := self.promptView() + promptView.ClearTextArea() + promptView.TextArea.TypeString(context.GetFilter()) + promptView.RenderTextArea() + + if err := self.c.PushContext(self.c.Contexts().Search); err != nil { + return err + } + + return nil +} + +func (self *SearchHelper) OpenSearchPrompt(context types.ISearchableContext) error { + state := self.searchState() + + state.Context = context + searchString := context.GetSearchString() + + self.searchPrefixView().SetContent(self.c.Tr.SearchPrefix) + promptView := self.promptView() + promptView.ClearTextArea() + promptView.TextArea.TypeString(searchString) + promptView.RenderTextArea() + + if err := self.c.PushContext(self.c.Contexts().Search); err != nil { + return err + } + + return nil +} + +func (self *SearchHelper) DisplayFilterStatus(context types.IFilterableContext) { + state := self.searchState() + + state.Context = context + searchString := context.GetFilter() + + self.searchPrefixView().SetContent(self.c.Tr.FilterPrefix) + + promptView := self.promptView() + keybindingConfig := self.c.UserConfig.Keybinding + promptView.SetContent(fmt.Sprintf("matches for '%s' ", searchString) + theme.OptionsFgColor.Sprintf(self.c.Tr.ExitTextFilterMode, keybindings.Label(keybindingConfig.Universal.Return))) +} + +func (self *SearchHelper) DisplaySearchStatus(context types.ISearchableContext) { + state := self.searchState() + + state.Context = context + + self.searchPrefixView().SetContent(self.c.Tr.SearchPrefix) + _ = context.GetView().SelectCurrentSearchResult() +} + +func (self *SearchHelper) searchState() *types.SearchState { + return self.c.State().GetRepoState().GetSearchState() +} + +func (self *SearchHelper) searchPrefixView() *gocui.View { + return self.c.Views().SearchPrefix +} + +func (self *SearchHelper) promptView() *gocui.View { + return self.c.Contexts().Search.GetView() +} + +func (self *SearchHelper) promptContent() string { + return self.c.Contexts().Search.GetView().TextArea.GetContent() +} + +func (self *SearchHelper) Confirm() error { + state := self.searchState() + if self.promptContent() == "" { + return self.CancelPrompt() + } + + switch state.SearchType() { + case types.SearchTypeFilter: + return self.ConfirmFilter() + case types.SearchTypeSearch: + return self.ConfirmSearch() + case types.SearchTypeNone: + return self.c.PopContext() + } + + return nil +} + +func (self *SearchHelper) ConfirmFilter() error { + // We also do this on each keypress but we do it here again just in case + state := self.searchState() + + _, ok := state.Context.(types.IFilterableContext) + if !ok { + self.c.Log.Warnf("Context %s is not filterable", state.Context.GetKey()) + return nil + } + + self.OnPromptContentChanged(self.promptContent()) + + return self.c.PopContext() +} + +func (self *SearchHelper) ConfirmSearch() error { + state := self.searchState() + + context, ok := state.Context.(types.ISearchableContext) + if !ok { + self.c.Log.Warnf("Context %s is searchable", state.Context.GetKey()) + return nil + } + + searchString := self.promptContent() + context.SetSearchString(searchString) + + view := context.GetView() + + if err := self.c.PopContext(); err != nil { + return err + } + + if err := view.Search(searchString); err != nil { + return err + } + + return nil +} + +func (self *SearchHelper) CancelPrompt() error { + self.Cancel() + + return self.c.PopContext() +} + +func (self *SearchHelper) Cancel() { + state := self.searchState() + + switch context := state.Context.(type) { + case types.IFilterableContext: + context.ClearFilter() + _ = self.c.PostRefreshUpdate(context) + case types.ISearchableContext: + context.ClearSearchString() + context.GetView().ClearSearch() + default: + // do nothing + } + + self.HidePrompt() +} + +func (self *SearchHelper) OnPromptContentChanged(searchString string) { + state := self.searchState() + switch context := state.Context.(type) { + case types.IFilterableContext: + context.SetSelectedLineIdx(0) + _ = context.GetView().SetOriginY(0) + context.SetFilter(searchString) + _ = self.c.PostRefreshUpdate(context) + case types.ISearchableContext: + // do nothing + default: + // do nothing (shouldn't land here) + } +} + +func (self *SearchHelper) RenderSearchStatus(c types.Context) { + if c.GetKey() == context.SEARCH_CONTEXT_KEY { + return + } + + if searchableContext, ok := c.(types.ISearchableContext); ok { + if searchableContext.IsSearching() { + self.setSearchingFrameColor() + self.DisplaySearchStatus(searchableContext) + return + } + } + if filterableContext, ok := c.(types.IFilterableContext); ok { + if filterableContext.IsFiltering() { + self.setSearchingFrameColor() + self.DisplayFilterStatus(filterableContext) + return + } + } + + self.HidePrompt() +} + +func (self *SearchHelper) CancelSearchIfSearching(c types.Context) { + if searchableContext, ok := c.(types.ISearchableContext); ok { + view := searchableContext.GetView() + if view != nil && view.IsSearching() { + view.ClearSearch() + searchableContext.ClearSearchString() + self.Cancel() + } + return + } + + if filterableContext, ok := c.(types.IFilterableContext); ok { + if filterableContext.IsFiltering() { + filterableContext.ClearFilter() + self.Cancel() + } + return + } +} + +func (self *SearchHelper) HidePrompt() { + self.setNonSearchingFrameColor() + + state := self.searchState() + state.Context = nil +} + +func (self *SearchHelper) setSearchingFrameColor() { + self.c.GocuiGui().SelFgColor = theme.SearchingActiveBorderColor + self.c.GocuiGui().SelFrameColor = theme.SearchingActiveBorderColor +} + +func (self *SearchHelper) setNonSearchingFrameColor() { + self.c.GocuiGui().SelFgColor = theme.ActiveBorderColor + self.c.GocuiGui().SelFrameColor = theme.ActiveBorderColor +} diff --git a/pkg/gui/controllers/helpers/window_arrangement_helper.go b/pkg/gui/controllers/helpers/window_arrangement_helper.go index 20459993f..b45586764 100644 --- a/pkg/gui/controllers/helpers/window_arrangement_helper.go +++ b/pkg/gui/controllers/helpers/window_arrangement_helper.go @@ -55,7 +55,7 @@ func (self *WindowArrangementHelper) GetWindowDimensions(informationStr string, self.c.Modes().Filtering.Active() showInfoSection := self.c.UserConfig.Gui.ShowBottomLine || - self.c.State().GetRepoState().IsSearching() || + self.c.State().GetRepoState().InSearchPrompt() || self.modeHelper.IsAnyModeActive() || self.appStatusHelper.HasStatus() infoSectionSize := 0 @@ -174,11 +174,17 @@ func (self *WindowArrangementHelper) getMidSectionWeights() (int, int) { } func (self *WindowArrangementHelper) infoSectionChildren(informationStr string, appStatus string) []*boxlayout.Box { - if self.c.State().GetRepoState().IsSearching() { + if self.c.State().GetRepoState().InSearchPrompt() { + var prefix string + if self.c.State().GetRepoState().GetSearchState().SearchType() == types.SearchTypeSearch { + prefix = self.c.Tr.SearchPrefix + } else { + prefix = self.c.Tr.FilterPrefix + } return []*boxlayout.Box{ { Window: "searchPrefix", - Size: runewidth.StringWidth(self.c.Tr.SearchPrefix), + Size: runewidth.StringWidth(prefix), }, { Window: "search", diff --git a/pkg/gui/controllers/list_controller.go b/pkg/gui/controllers/list_controller.go index 2f995ebc8..fb6d8736a 100644 --- a/pkg/gui/controllers/list_controller.go +++ b/pkg/gui/controllers/list_controller.go @@ -150,18 +150,7 @@ func (self *ListController) GetKeybindings(opts types.KeybindingsOpts) []*types. {Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.GotoTop), Handler: self.HandleGotoTop, Description: self.c.Tr.GotoTop}, {Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.ScrollLeft), Handler: self.HandleScrollLeft}, {Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.ScrollRight), Handler: self.HandleScrollRight}, - { - Key: opts.GetKey(opts.Config.Universal.StartSearch), - Handler: func() error { self.c.OpenSearch(); return nil }, - Description: self.c.Tr.StartSearch, - Tag: "navigation", - }, - { - Key: opts.GetKey(opts.Config.Universal.GotoBottom), - Description: self.c.Tr.GotoBottom, - Handler: self.HandleGotoBottom, - Tag: "navigation", - }, + {Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.GotoBottom), Handler: self.HandleGotoBottom, Description: self.c.Tr.GotoBottom}, } } diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index 0ba80c768..49abe02ff 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -693,9 +693,7 @@ func (self *LocalCommitsController) openSearch() error { } } - self.c.OpenSearch() - - return nil + return self.c.Helpers().Search.OpenSearchPrompt(self.context()) } func (self *LocalCommitsController) gotoBottom() error { diff --git a/pkg/gui/controllers/patch_explorer_controller.go b/pkg/gui/controllers/patch_explorer_controller.go index 6de8fb8b9..dd19d08db 100644 --- a/pkg/gui/controllers/patch_explorer_controller.go +++ b/pkg/gui/controllers/patch_explorer_controller.go @@ -124,12 +124,6 @@ func (self *PatchExplorerController) GetKeybindings(opts types.KeybindingsOpts) Handler: self.withRenderAndFocus(self.HandleScrollRight), }, { - Tag: "navigation", - Key: opts.GetKey(opts.Config.Universal.StartSearch), - Handler: func() error { self.c.OpenSearch(); return nil }, - Description: self.c.Tr.StartSearch, - }, - { Key: opts.GetKey(opts.Config.Universal.CopyToClipboard), Handler: self.withLock(self.CopySelectedToClipboard), Description: self.c.Tr.CopySelectedTexToClipboard, diff --git a/pkg/gui/controllers/quit_actions.go b/pkg/gui/controllers/quit_actions.go index 2487a62fe..a163f66c8 100644 --- a/pkg/gui/controllers/quit_actions.go +++ b/pkg/gui/controllers/quit_actions.go @@ -50,6 +50,19 @@ func (self *QuitActions) confirmQuitDuringUpdate() error { func (self *QuitActions) Escape() error { currentContext := self.c.CurrentContext() + switch ctx := currentContext.(type) { + case types.IFilterableContext: + if ctx.IsFiltering() { + self.c.Helpers().Search.Cancel() + return nil + } + case types.ISearchableContext: + if ctx.IsSearching() { + self.c.Helpers().Search.Cancel() + return nil + } + } + parentContext, hasParent := currentContext.GetParentContext() if hasParent && currentContext != nil && parentContext != nil { // TODO: think about whether this should be marked as a return rather than adding to the stack 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 @@ -60,11 +60,6 @@ func (self *RemoteBranchesController) GetKeybindings(opts types.KeybindingsOpts) 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), Description: self.c.Tr.ViewResetOptions, @@ -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/gui/controllers/search_controller.go b/pkg/gui/controllers/search_controller.go new file mode 100644 index 000000000..395784d10 --- /dev/null +++ b/pkg/gui/controllers/search_controller.go @@ -0,0 +1,48 @@ +package controllers + +import ( + "github.com/jesseduffield/lazygit/pkg/gui/types" +) + +type SearchControllerFactory struct { + c *ControllerCommon +} + +func NewSearchControllerFactory(c *ControllerCommon) *SearchControllerFactory { + return &SearchControllerFactory{ + c: c, + } +} + +func (self *SearchControllerFactory) Create(context types.ISearchableContext) *SearchController { + return &SearchController{ + baseController: baseController{}, + c: self.c, + context: context, + } +} + +type SearchController struct { + baseController + c *ControllerCommon + + context types.ISearchableContext +} + +func (self *SearchController) Context() types.Context { + return self.context +} + +func (self *SearchController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding { + return []*types.Binding{ + { + Key: opts.GetKey(opts.Config.Universal.StartSearch), + Handler: self.OpenSearchPrompt, + Description: self.c.Tr.StartSearch, + }, + } +} + +func (self *SearchController) OpenSearchPrompt() error { + return self.c.Helpers().Search.OpenSearchPrompt(self.context) +} diff --git a/pkg/gui/controllers/search_prompt_controller.go b/pkg/gui/controllers/search_prompt_controller.go new file mode 100644 index 000000000..2326ed1c1 --- /dev/null +++ b/pkg/gui/controllers/search_prompt_controller.go @@ -0,0 +1,53 @@ +package controllers + +import ( + "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gui/types" +) + +type SearchPromptController struct { + baseController + c *ControllerCommon +} + +var _ types.IController = &SearchPromptController{} + +func NewSearchPromptController( + common *ControllerCommon, +) *SearchPromptController { + return &SearchPromptController{ + baseController: baseController{}, + c: common, + } +} + +func (self *SearchPromptController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding { + return []*types.Binding{ + { + Key: opts.GetKey(opts.Config.Universal.Confirm), + Modifier: gocui.ModNone, + Handler: self.confirm, + }, + { + Key: opts.GetKey(opts.Config.Universal.Return), + Modifier: gocui.ModNone, + Handler: self.cancel, + }, + } +} + +func (self *SearchPromptController) Context() types.Context { + return self.context() +} + +func (self *SearchPromptController) context() types.Context { + return self.c.Contexts().Search +} + +func (self *SearchPromptController) confirm() error { + return self.c.Helpers().Search.Confirm() +} + +func (self *SearchPromptController) cancel() error { + return self.c.Helpers().Search.CancelPrompt() +} diff --git a/pkg/gui/controllers/switch_to_diff_files_controller.go b/pkg/gui/controllers/switch_to_diff_files_controller.go index ffec6936e..971efb7a1 100644 --- a/pkg/gui/controllers/switch_to_diff_files_controller.go +++ b/pkg/gui/controllers/switch_to_diff_files_controller.go @@ -83,6 +83,7 @@ func (self *SwitchToDiffFilesController) viewFiles(opts SwitchToCommitFilesConte diffFilesContext.SetCanRebase(opts.CanRebase) diffFilesContext.SetParentContext(opts.Context) diffFilesContext.SetWindowName(opts.Context.GetWindowName()) + diffFilesContext.ClearSearchString() if err := self.c.Refresh(types.RefreshOptions{ Scope: []types.RefreshableView{types.COMMIT_FILES}, diff --git a/pkg/gui/controllers/switch_to_sub_commits_controller.go b/pkg/gui/controllers/switch_to_sub_commits_controller.go index 5ae86f02b..8163181e5 100644 --- a/pkg/gui/controllers/switch_to_sub_commits_controller.go +++ b/pkg/gui/controllers/switch_to_sub_commits_controller.go @@ -71,12 +71,15 @@ func (self *SwitchToSubCommitsController) viewCommits() error { self.setSubCommits(commits) - self.c.Contexts().SubCommits.SetSelectedLineIdx(0) - self.c.Contexts().SubCommits.SetParentContext(self.context) - self.c.Contexts().SubCommits.SetWindowName(self.context.GetWindowName()) - self.c.Contexts().SubCommits.SetTitleRef(ref.Description()) - self.c.Contexts().SubCommits.SetRef(ref) - self.c.Contexts().SubCommits.SetLimitCommits(true) + subCommitsContext := self.c.Contexts().SubCommits + subCommitsContext.SetSelectedLineIdx(0) + subCommitsContext.SetParentContext(self.context) + subCommitsContext.SetWindowName(self.context.GetWindowName()) + subCommitsContext.SetTitleRef(ref.Description()) + subCommitsContext.SetRef(ref) + subCommitsContext.SetLimitCommits(true) + subCommitsContext.ClearSearchString() + subCommitsContext.GetView().ClearSearch() err = self.c.PostRefreshUpdate(self.c.Contexts().SubCommits) if err != nil { |