From 4116a15dae1e9da71254ff6b5b0cc5bff5b80ca5 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 25 Aug 2026 09:51:16 +0200 Subject: [PATCH] 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) --- pkg/gui/controllers/helpers/repos_helper.go | 6 ++- .../tests/misc/filter_recent_repos.go | 37 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 pkg/integration/tests/misc/filter_recent_repos.go diff --git a/pkg/gui/controllers/helpers/repos_helper.go b/pkg/gui/controllers/helpers/repos_helper.go index d3b6bfe29..c8a33bcbe 100644 --- a/pkg/gui/controllers/helpers/repos_helper.go +++ b/pkg/gui/controllers/helpers/repos_helper.go @@ -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 diff --git a/pkg/integration/tests/misc/filter_recent_repos.go b/pkg/integration/tests/misc/filter_recent_repos.go new file mode 100644 index 000000000..a54ca51db --- /dev/null +++ b/pkg/integration/tests/misc/filter_recent_repos.go @@ -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")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 7bc50fe18..5ac4bdcba 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -360,6 +360,7 @@ var tests = []*components.IntegrationTest{ misc.DirenvApprovesEnvrc, misc.DirenvLoadedOnRepoSwitch, misc.DirenvUnloadsOnBlockedEnvrc, + misc.FilterRecentRepos, misc.InitialOpen, misc.RecentReposOnLaunch, misc.StartInGitDir,