1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-23 22:24:51 +02:00

When entering a commit in path filtering mode, select the filtered path

This commit is contained in:
Stefan Haller
2025-10-06 10:31:24 +02:00
parent 5811f2945c
commit 7fe73c1ee2
5 changed files with 119 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
package filter_by_path
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var SelectFilteredFileWhenEnteringCommit = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Filter commits by file path, then enter a commit and ensure the file is selected",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {
},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file1", "")
shell.CreateFileAndAdd("dir/file2", "")
shell.Commit("add files")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.GlobalPress(keys.Universal.FilteringMenu)
t.ExpectPopup().Menu().
Title(Equals("Filtering")).
Select(Contains("Enter path to filter by")).
Confirm()
t.ExpectPopup().Prompt().
Title(Equals("Enter path:")).
Type("dir/file2").
Confirm()
t.Views().Commits().
Focus().
Lines(
Contains("add files").IsSelected(),
).
PressEnter()
t.Views().CommitFiles().
IsFocused().
Lines(
Equals("▼ /"),
Equals(" ▼ dir"),
Equals(" A file2").IsSelected(),
Equals(" A file1"),
)
},
})

View File

@@ -0,0 +1,47 @@
package filter_by_path
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var SelectFilteredFileWhenEnteringCommitNoRootItem = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Filter commits by file path, then enter a commit and ensure the file is selected (with the show root item config off)",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Gui.ShowRootItemInFileTree = false
},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file1", "")
shell.CreateFileAndAdd("dir/file2", "")
shell.Commit("add files")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.GlobalPress(keys.Universal.FilteringMenu)
t.ExpectPopup().Menu().
Title(Equals("Filtering")).
Select(Contains("Enter path to filter by")).
Confirm()
t.ExpectPopup().Prompt().
Title(Equals("Enter path:")).
Type("dir/file2").
Confirm()
t.Views().Commits().
Focus().
Lines(
Contains("add files").IsSelected(),
).
PressEnter()
t.Views().CommitFiles().
IsFocused().
Lines(
Equals("▼ dir"),
Equals(" A file2").IsSelected(),
Equals("A file1"),
)
},
})

View File

@@ -242,6 +242,8 @@ var tests = []*components.IntegrationTest{
filter_by_path.KeepSameCommitSelectedOnExit,
filter_by_path.RewordCommitInFilteringMode,
filter_by_path.SelectFile,
filter_by_path.SelectFilteredFileWhenEnteringCommit,
filter_by_path.SelectFilteredFileWhenEnteringCommitNoRootItem,
filter_by_path.ShowDiffsForRenamedFile,
filter_by_path.TypeFile,
interactive_rebase.AdvancedInteractiveRebase,