mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-28 16:02:01 +03:00
Fix stale main view content when entering/exiting filtering view
When entering filtering we would only call FocusLine, which takes care of highlighting the selected line in the commits list, but not of re-rendering the main view. HandleFocus does that. When exiting filtering, the HandleFocus call was missing entirely. The tests needed to be reworked a little bit to make this testable.
This commit is contained in:
@ -124,7 +124,7 @@ func (self *FilteringMenuAction) setFiltering() error {
|
|||||||
|
|
||||||
self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() {
|
self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() {
|
||||||
self.c.Contexts().LocalCommits.SetSelection(0)
|
self.c.Contexts().LocalCommits.SetSelection(0)
|
||||||
self.c.Contexts().LocalCommits.FocusLine()
|
self.c.Contexts().LocalCommits.HandleFocus(types.OnFocusOpts{})
|
||||||
}})
|
}})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -178,6 +178,7 @@ func (self *ModeHelper) ClearFiltering() error {
|
|||||||
// before we entered filtering
|
// before we entered filtering
|
||||||
self.c.Contexts().LocalCommits.SelectCommitByHash(self.c.Modes().Filtering.GetSelectedCommitHash())
|
self.c.Contexts().LocalCommits.SelectCommitByHash(self.c.Modes().Filtering.GetSelectedCommitHash())
|
||||||
}
|
}
|
||||||
|
self.c.Contexts().LocalCommits.HandleFocus(types.OnFocusOpts{})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
|
@ -19,9 +19,9 @@ var KeepSameCommitSelectedOnExit = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Focus().
|
Focus().
|
||||||
Lines(
|
Lines(
|
||||||
Contains(`none of the two`).IsSelected(),
|
Contains(`none of the two`).IsSelected(),
|
||||||
Contains(`only filterFile`),
|
|
||||||
Contains(`only otherFile`),
|
|
||||||
Contains(`both files`),
|
Contains(`both files`),
|
||||||
|
Contains(`only otherFile`),
|
||||||
|
Contains(`only filterFile`),
|
||||||
).Press(keys.Universal.FilteringMenu).
|
).Press(keys.Universal.FilteringMenu).
|
||||||
Tap(func() {
|
Tap(func() {
|
||||||
t.ExpectPopup().Menu().
|
t.ExpectPopup().Menu().
|
||||||
@ -36,16 +36,33 @@ var KeepSameCommitSelectedOnExit = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
ConfirmFirstSuggestion()
|
ConfirmFirstSuggestion()
|
||||||
}).
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
Contains(`only filterFile`).IsSelected(),
|
Contains(`both files`).IsSelected(),
|
||||||
Contains(`both files`),
|
Contains(`only filterFile`),
|
||||||
).
|
).
|
||||||
SelectNextItem().
|
Tap(func() {
|
||||||
|
t.Views().Main().
|
||||||
|
ContainsLines(
|
||||||
|
Equals(" both files"),
|
||||||
|
Equals("---"),
|
||||||
|
Equals(" filterFile | 2 +-"),
|
||||||
|
Equals(" 1 file changed, 1 insertion(+), 1 deletion(-)"),
|
||||||
|
)
|
||||||
|
}).
|
||||||
PressEscape().
|
PressEscape().
|
||||||
Lines(
|
Lines(
|
||||||
Contains(`none of the two`),
|
Contains(`none of the two`),
|
||||||
Contains(`only filterFile`),
|
|
||||||
Contains(`only otherFile`),
|
|
||||||
Contains(`both files`).IsSelected(),
|
Contains(`both files`).IsSelected(),
|
||||||
|
Contains(`only otherFile`),
|
||||||
|
Contains(`only filterFile`),
|
||||||
|
)
|
||||||
|
|
||||||
|
t.Views().Main().
|
||||||
|
ContainsLines(
|
||||||
|
Equals(" both files"),
|
||||||
|
Equals("---"),
|
||||||
|
Equals(" filterFile | 2 +-"),
|
||||||
|
Equals(" otherFile | 2 +-"),
|
||||||
|
Equals(" 2 files changed, 2 insertions(+), 2 deletions(-)"),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -19,22 +19,25 @@ var SelectFile = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Focus().
|
Focus().
|
||||||
Lines(
|
Lines(
|
||||||
Contains(`none of the two`).IsSelected(),
|
Contains(`none of the two`).IsSelected(),
|
||||||
Contains(`only filterFile`),
|
|
||||||
Contains(`only otherFile`),
|
|
||||||
Contains(`both files`),
|
Contains(`both files`),
|
||||||
|
Contains(`only otherFile`),
|
||||||
|
Contains(`only filterFile`),
|
||||||
).
|
).
|
||||||
NavigateToLine(Contains(`only filterFile`)).
|
NavigateToLine(Contains(`both files`)).
|
||||||
PressEnter()
|
PressEnter()
|
||||||
|
|
||||||
// when you click into the commit itself, you see all files from that commit
|
|
||||||
t.Views().CommitFiles().
|
t.Views().CommitFiles().
|
||||||
IsFocused().
|
IsFocused().
|
||||||
Lines(
|
Lines(
|
||||||
Contains(`filterFile`).IsSelected(),
|
Equals(`▼ /`).IsSelected(),
|
||||||
|
Equals(` M filterFile`),
|
||||||
|
Equals(` M otherFile`),
|
||||||
).
|
).
|
||||||
|
SelectNextItem().
|
||||||
Press(keys.Universal.FilteringMenu)
|
Press(keys.Universal.FilteringMenu)
|
||||||
|
|
||||||
t.ExpectPopup().Menu().Title(Equals("Filtering")).Select(Contains("Filter by 'filterFile'")).Confirm()
|
t.ExpectPopup().Menu().Title(Equals("Filtering")).
|
||||||
|
Select(Contains("Filter by 'filterFile'")).Confirm()
|
||||||
|
|
||||||
postFilterTest(t)
|
postFilterTest(t)
|
||||||
},
|
},
|
||||||
|
@ -6,14 +6,13 @@ import (
|
|||||||
|
|
||||||
func commonSetup(shell *Shell) {
|
func commonSetup(shell *Shell) {
|
||||||
shell.CreateFileAndAdd("filterFile", "original filterFile content")
|
shell.CreateFileAndAdd("filterFile", "original filterFile content")
|
||||||
|
shell.Commit("only filterFile")
|
||||||
shell.CreateFileAndAdd("otherFile", "original otherFile content")
|
shell.CreateFileAndAdd("otherFile", "original otherFile content")
|
||||||
shell.Commit("both files")
|
|
||||||
|
|
||||||
shell.UpdateFileAndAdd("otherFile", "new otherFile content")
|
|
||||||
shell.Commit("only otherFile")
|
shell.Commit("only otherFile")
|
||||||
|
|
||||||
|
shell.UpdateFileAndAdd("otherFile", "new otherFile content")
|
||||||
shell.UpdateFileAndAdd("filterFile", "new filterFile content")
|
shell.UpdateFileAndAdd("filterFile", "new filterFile content")
|
||||||
shell.Commit("only filterFile")
|
shell.Commit("both files")
|
||||||
|
|
||||||
shell.EmptyCommit("none of the two")
|
shell.EmptyCommit("none of the two")
|
||||||
}
|
}
|
||||||
@ -24,14 +23,18 @@ func postFilterTest(t *TestDriver) {
|
|||||||
t.Views().Commits().
|
t.Views().Commits().
|
||||||
IsFocused().
|
IsFocused().
|
||||||
Lines(
|
Lines(
|
||||||
Contains(`only filterFile`).IsSelected(),
|
Contains(`both files`).IsSelected(),
|
||||||
Contains(`both files`),
|
Contains(`only filterFile`),
|
||||||
).
|
)
|
||||||
SelectNextItem()
|
|
||||||
|
|
||||||
// we only show the filtered file's changes in the main view
|
// we only show the filtered file's changes in the main view
|
||||||
t.Views().Main().
|
t.Views().Main().
|
||||||
Content(Contains("filterFile").DoesNotContain("otherFile"))
|
ContainsLines(
|
||||||
|
Equals(" both files"),
|
||||||
|
Equals("---"),
|
||||||
|
Equals(" filterFile | 2 +-"),
|
||||||
|
Equals(" 1 file changed, 1 insertion(+), 1 deletion(-)"),
|
||||||
|
)
|
||||||
|
|
||||||
t.Views().Commits().
|
t.Views().Commits().
|
||||||
PressEnter()
|
PressEnter()
|
||||||
|
Reference in New Issue
Block a user