diff options
author | Karim Khaleel <code.karim@gmail.com> | 2023-08-04 14:01:30 +0300 |
---|---|---|
committer | Karim Khaleel <code.karim@gmail.com> | 2023-09-20 08:35:41 +0300 |
commit | edec116cebe6dde1f8e7ce375fabc407c84d92b5 (patch) | |
tree | bbc27be98cc27ad51fe8d55df23bf9d66a2698ab /pkg/gui/types | |
parent | ab5875c78fcd7fc2f0cdbc867dc84ef4331a5de3 (diff) |
Add search history
Add search history for filterable and searchable views.
Diffstat (limited to 'pkg/gui/types')
-rw-r--r-- | pkg/gui/types/context.go | 9 | ||||
-rw-r--r-- | pkg/gui/types/search_state.go | 5 |
2 files changed, 12 insertions, 2 deletions
diff --git a/pkg/gui/types/context.go b/pkg/gui/types/context.go index dca5b042c..e06138a99 100644 --- a/pkg/gui/types/context.go +++ b/pkg/gui/types/context.go @@ -4,6 +4,7 @@ import ( "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/gui/patch_exploring" + "github.com/jesseduffield/lazygit/pkg/utils" "github.com/sasha-s/go-deadlock" ) @@ -87,9 +88,16 @@ type Context interface { HandleRenderToMain() error } +type ISearchHistoryContext interface { + Context + + GetSearchHistory() *utils.HistoryBuffer[string] +} + type IFilterableContext interface { Context IListPanelState + ISearchHistoryContext SetFilter(string) GetFilter() string @@ -100,6 +108,7 @@ type IFilterableContext interface { type ISearchableContext interface { Context + ISearchHistoryContext SetSearchString(string) GetSearchString() string diff --git a/pkg/gui/types/search_state.go b/pkg/gui/types/search_state.go index 9b24af095..af806f2c3 100644 --- a/pkg/gui/types/search_state.go +++ b/pkg/gui/types/search_state.go @@ -12,11 +12,12 @@ const ( // TODO: could we remove this entirely? type SearchState struct { - Context Context + Context Context + PrevSearchIndex int } func NewSearchState() *SearchState { - return &SearchState{} + return &SearchState{PrevSearchIndex: -1} } func (self *SearchState) SearchType() SearchType { |