mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Cover how a view's selection follows the focus in and out of a context
Nothing said that a context leaving the stack takes its selection with it, which the work coming up is about to make the rule for every view. Two places already depend on it and are held together by hand: switching repos, where the view focused in the repo being left is not the one focused in the repo being entered, and tabbing from the suggestions list back to the prompt, which replaces the top of the stack rather than popping it. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1b2bd85fc5
commit
eb760ee928
|
|
@ -526,6 +526,8 @@ var tests = []*components.IntegrationTest{
|
|||
ui.ReloadSidePanels,
|
||||
ui.ReorderSidePanels,
|
||||
ui.SubCommitsScrollPositionIsReset,
|
||||
ui.SuggestionsSelectionFollowsTheFocus,
|
||||
ui.SwitchRepoMovesTheSelection,
|
||||
ui.SwitchTabFromMenu,
|
||||
ui.SwitchTabWithPanelJumpKeys,
|
||||
undo.UndoCheckoutAndDrop,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var SuggestionsSelectionFollowsTheFocus = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "The suggestions list only shows a selection while it, rather than the prompt, has the focus",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.
|
||||
EmptyCommit("one").
|
||||
NewBranch("branch-to-checkout")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Press(keys.Branches.CheckoutBranchByName)
|
||||
|
||||
t.ExpectPopup().Prompt().
|
||||
Title(Equals("Branch name:")).
|
||||
Type("branch-to").
|
||||
SuggestionTopLines(Contains("branch-to-checkout"))
|
||||
|
||||
t.Views().Suggestions().SelectionIsHidden()
|
||||
|
||||
t.Views().Prompt().Press(keys.Universal.TogglePanel)
|
||||
t.Views().Suggestions().
|
||||
IsFocused().
|
||||
SelectionIsActive().
|
||||
Press(keys.Universal.TogglePanel)
|
||||
|
||||
t.Views().Prompt().IsFocused()
|
||||
t.Views().Suggestions().SelectionIsHidden()
|
||||
|
||||
t.Views().Prompt().Press(keys.Universal.Return)
|
||||
t.Views().Branches().IsFocused()
|
||||
},
|
||||
})
|
||||
48
pkg/integration/tests/ui/switch_repo_moves_the_selection.go
Normal file
48
pkg/integration/tests/ui/switch_repo_moves_the_selection.go
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var SwitchRepoMovesTheSelection = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "The selection follows the focus of the repo being switched to, rather than the one being left",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
otherRepo, _ := filepath.Abs("../other")
|
||||
config.GetAppState().RecentRepos = []string{otherRepo}
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CloneNonBare("other")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
switchToRepo := func(repo string) {
|
||||
t.GlobalPress(keys.Universal.OpenRecentRepos)
|
||||
t.ExpectPopup().Menu().Title(Equals("Recent repositories")).
|
||||
Lines(
|
||||
Contains(repo).IsSelected(),
|
||||
Contains("Cancel"),
|
||||
).Confirm()
|
||||
t.Views().Status().Content(Contains(repo + " → master"))
|
||||
}
|
||||
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
SelectionIsActive()
|
||||
|
||||
// The other repo has its own focus, which is the files panel it starts in
|
||||
switchToRepo("other")
|
||||
t.Views().Files().IsFocused()
|
||||
t.Views().Branches().SelectionIsHidden()
|
||||
|
||||
// And coming back, this repo still has the focus we left it with
|
||||
switchToRepo("repo")
|
||||
t.Views().Branches().
|
||||
IsFocused().
|
||||
SelectionIsActive()
|
||||
t.Views().Files().SelectionIsHidden()
|
||||
},
|
||||
})
|
||||
Loading…
Reference in a new issue