diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 9b2e29c02..3d924a566 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -171,15 +171,9 @@ func (gui *Gui) postRefreshUpdate(c types.Context, opts types.OnFocusOpts) { currentCtx := gui.State.ContextMgr.Current() if currentCtx.GetKey() == context.NORMAL_MAIN_CONTEXT_KEY || currentCtx.GetKey() == context.NORMAL_SECONDARY_CONTEXT_KEY { - // Searching can't cope well with the view being updated while it is being searched. - // We might be able to fix the problems with this, but it doesn't seem easy, so for now - // just don't rerender the view while searching, on the assumption that users will probably - // either search or change their data, but not both at the same time. - if !currentCtx.GetView().IsSearching() { - sidePanelContext := gui.State.ContextMgr.NextInStack(currentCtx) - if sidePanelContext != nil && sidePanelContext.GetKey() == c.GetKey() { - sidePanelContext.HandleRenderToMain() - } + sidePanelContext := gui.State.ContextMgr.NextInStack(currentCtx) + if sidePanelContext != nil && sidePanelContext.GetKey() == c.GetKey() { + sidePanelContext.HandleRenderToMain() } } else if c.GetKey() == gui.State.ContextMgr.CurrentStatic().GetKey() { // If our view is not the current one, but it is the current static context, then this diff --git a/pkg/integration/tests/filter_and_search/rerender_the_searched_main_view.go b/pkg/integration/tests/filter_and_search/rerender_the_searched_main_view.go new file mode 100644 index 000000000..3d631e650 --- /dev/null +++ b/pkg/integration/tests/filter_and_search/rerender_the_searched_main_view.go @@ -0,0 +1,37 @@ +package filter_and_search + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var RerenderTheSearchedMainView = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "A refresh renders the focused main view again even while it is being searched", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFileAndAdd("file1", "one\ntwo\nthree\n") + shell.Commit("one") + + shell.UpdateFile("file1", "one\nNEEDLE\nthree\n") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Files(). + IsFocused(). + Press(keys.Universal.FocusMainView) + + t.Views().Main(). + IsFocused(). + FilterOrSearch("NEEDLE"). + Content(Contains("+NEEDLE")). + Tap(func() { + t.Shell().UpdateFile("file1", "one\nOTHER\nthree\n") + }). + Press(keys.Universal.Refresh). + Content(Contains("+OTHER")). + Content(DoesNotContain("+NEEDLE")) + + t.Views().Search().Content(Contains("No matches for 'NEEDLE'")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 3d9edadfe..a4e732cf0 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -277,6 +277,7 @@ var tests = []*components.IntegrationTest{ filter_and_search.NestedFilter, filter_and_search.NestedFilterTransient, filter_and_search.NewSearch, + filter_and_search.RerenderTheSearchedMainView, filter_and_search.SearchALongDiff, filter_and_search.SearchStatusAfterARerender, filter_and_search.StageAllStagesOnlyTrackedFilesInTrackedOnlyFilter,