mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Render the focused main view again while it is being searched
A refresh left the focused main view alone while a search was on, so the diff on screen stayed as it was however much the working tree had moved on underneath it. The search could not cope with the content changing under it, and leaving the content alone was the way around that. It can cope now. The positions are worked out again from whatever the view holds, and the status with them, so render it like any other. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
811b3fbdd1
commit
114d3a5a25
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'"))
|
||||
},
|
||||
})
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue