Filter the recent repositories menu as you type

Picking a repository out of that list is the other place where the menu is
a list to search rather than a set of commands, and its items have no keys
that typing could clash with.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller 2026-08-25 09:51:16 +02:00
parent bb7e74968b
commit 4116a15dae
3 changed files with 43 additions and 1 deletions

View file

@ -153,7 +153,11 @@ func (self *ReposHelper) CreateRecentReposMenu() error {
}
})
return self.c.Menu(types.CreateMenuOptions{Title: self.c.Tr.RecentRepos, Items: menuItems})
return self.c.Menu(types.CreateMenuOptions{
Title: self.c.Tr.RecentRepos,
Items: menuItems,
FilterAsYouType: true,
})
}
// SwitchToParentRepo switches back to the repo the current submodule was

View file

@ -0,0 +1,37 @@
package misc
import (
"path/filepath"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var FilterRecentRepos = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Switching to a recent repository by typing part of its name",
ExtraCmdArgs: []string{},
ExtraEnvVars: map[string]string{
"SHOW_RECENT_REPOS": "true",
},
Skip: false,
SetupConfig: func(cfg *config.AppConfig) {
// the first entry is the repo we're in, so it isn't offered
current, _ := filepath.Abs(".")
other, _ := filepath.Abs("../other")
target, _ := filepath.Abs("../target")
cfg.GetAppState().RecentRepos = []string{current, other, target}
},
SetupRepo: func(shell *Shell) {
shell.CloneNonBare("other")
shell.CloneNonBare("target")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.ExpectPopup().Menu().
Title(Equals("Recent repositories")).
Filter("target").
Lines(Contains("target").IsSelected()).
Confirm()
t.Views().Status().Content(Contains("target → master"))
},
})

View file

@ -360,6 +360,7 @@ var tests = []*components.IntegrationTest{
misc.DirenvApprovesEnvrc,
misc.DirenvLoadedOnRepoSwitch,
misc.DirenvUnloadsOnBlockedEnvrc,
misc.FilterRecentRepos,
misc.InitialOpen,
misc.RecentReposOnLaunch,
misc.StartInGitDir,