mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-06 22:33:07 +02:00
Fix stale main view content when entering/exiting filtering view (#4719)
- **PR Description** When filtering by path, the main view wouldn't update the diff properly when entering and exiting the filtering mode.
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.Contexts().LocalCommits.SetSelection(0)
|
||||
self.c.Contexts().LocalCommits.FocusLine()
|
||||
self.c.Contexts().LocalCommits.HandleFocus(types.OnFocusOpts{})
|
||||
}})
|
||||
|
||||
return nil
|
||||
|
@ -178,6 +178,7 @@ func (self *ModeHelper) ClearFiltering() error {
|
||||
// before we entered filtering
|
||||
self.c.Contexts().LocalCommits.SelectCommitByHash(self.c.Modes().Filtering.GetSelectedCommitHash())
|
||||
}
|
||||
self.c.Contexts().LocalCommits.HandleFocus(types.OnFocusOpts{})
|
||||
},
|
||||
})
|
||||
return nil
|
||||
|
@ -9,7 +9,9 @@ var CheckoutByName = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Try to checkout branch by name. Verify that it also works on the branch with the special name @.",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
config.GetUserConfig().Git.LocalBranchSortOrder = "alphabetical"
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.
|
||||
CreateNCommits(3).
|
||||
|
@ -11,6 +11,7 @@ var Delete = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
|
||||
config.GetUserConfig().Git.RemoteBranchSortOrder = "alphabetical"
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.
|
||||
|
@ -19,9 +19,9 @@ var KeepSameCommitSelectedOnExit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Focus().
|
||||
Lines(
|
||||
Contains(`none of the two`).IsSelected(),
|
||||
Contains(`only filterFile`),
|
||||
Contains(`only otherFile`),
|
||||
Contains(`both files`),
|
||||
Contains(`only otherFile`),
|
||||
Contains(`only filterFile`),
|
||||
).Press(keys.Universal.FilteringMenu).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Menu().
|
||||
@ -36,16 +36,33 @@ var KeepSameCommitSelectedOnExit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
ConfirmFirstSuggestion()
|
||||
}).
|
||||
Lines(
|
||||
Contains(`only filterFile`).IsSelected(),
|
||||
Contains(`both files`),
|
||||
Contains(`both files`).IsSelected(),
|
||||
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().
|
||||
Lines(
|
||||
Contains(`none of the two`),
|
||||
Contains(`only filterFile`),
|
||||
Contains(`only otherFile`),
|
||||
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().
|
||||
Lines(
|
||||
Contains(`none of the two`).IsSelected(),
|
||||
Contains(`only filterFile`),
|
||||
Contains(`only otherFile`),
|
||||
Contains(`both files`),
|
||||
Contains(`only otherFile`),
|
||||
Contains(`only filterFile`),
|
||||
).
|
||||
NavigateToLine(Contains(`only filterFile`)).
|
||||
NavigateToLine(Contains(`both files`)).
|
||||
PressEnter()
|
||||
|
||||
// when you click into the commit itself, you see all files from that commit
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains(`filterFile`).IsSelected(),
|
||||
Equals(`▼ /`).IsSelected(),
|
||||
Equals(` M filterFile`),
|
||||
Equals(` M otherFile`),
|
||||
).
|
||||
SelectNextItem().
|
||||
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)
|
||||
},
|
||||
|
@ -6,14 +6,13 @@ import (
|
||||
|
||||
func commonSetup(shell *Shell) {
|
||||
shell.CreateFileAndAdd("filterFile", "original filterFile content")
|
||||
shell.Commit("only filterFile")
|
||||
shell.CreateFileAndAdd("otherFile", "original otherFile content")
|
||||
shell.Commit("both files")
|
||||
|
||||
shell.UpdateFileAndAdd("otherFile", "new otherFile content")
|
||||
shell.Commit("only otherFile")
|
||||
|
||||
shell.UpdateFileAndAdd("otherFile", "new otherFile content")
|
||||
shell.UpdateFileAndAdd("filterFile", "new filterFile content")
|
||||
shell.Commit("only filterFile")
|
||||
shell.Commit("both files")
|
||||
|
||||
shell.EmptyCommit("none of the two")
|
||||
}
|
||||
@ -24,14 +23,18 @@ func postFilterTest(t *TestDriver) {
|
||||
t.Views().Commits().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains(`only filterFile`).IsSelected(),
|
||||
Contains(`both files`),
|
||||
).
|
||||
SelectNextItem()
|
||||
Contains(`both files`).IsSelected(),
|
||||
Contains(`only filterFile`),
|
||||
)
|
||||
|
||||
// we only show the filtered file's changes in the main view
|
||||
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().
|
||||
PressEnter()
|
||||
|
Reference in New Issue
Block a user