feat: ctrl+s searches everything; again narrows to the source you're in
Go to opens on All instead of the source you're in, so a search finds anything at once. ctrl+s again in Go to narrows to that source, and once more goes back to All; the hint names it. g/G go to the top and bottom of a list while browsing, and the tabs are Search, Favourites, Recent. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
45fd80b418
commit
57aec8a381
4 files changed
+146
-38
No files matched your search
@@ -42,11 +42,15 @@ func TestSearchLoaded(t *testing.T) {
|
||||
t.Fatalf("missing %q:\n%s", want, d.screen())
|
||||
}
|
||||
}
|
||||
d.typeText("api-key")
|
||||
if !strings.Contains(d.screen(), "no matches here · All searches everything") {
|
||||
d.typeText("api-key") // on All: found at once
|
||||
if !strings.Contains(d.screen(), "ctrl+s only platform-dev") {
|
||||
t.Errorf("no hint to narrow to the source:\n%s", d.screen())
|
||||
}
|
||||
d.send(ctrl('s'))
|
||||
if !strings.Contains(d.screen(), "no matches here · All searches everything") || !strings.Contains(d.screen(), "ctrl+s searches all") {
|
||||
t.Errorf("no hint to search everything:\n%s", d.screen())
|
||||
}
|
||||
d.searchAll()
|
||||
d.send(ctrl('s'))
|
||||
if !strings.Contains(d.screen(), "platform-prod / kv-app-prod / api-key") {
|
||||
t.Fatalf("loaded secret not found:\n%s", d.screen())
|
||||
}
|
||||
@@ -62,7 +66,8 @@ func TestSearchLoaded(t *testing.T) {
|
||||
func TestSearchLoadsAsYouType(t *testing.T) {
|
||||
t.Parallel()
|
||||
d := newDriver(t)
|
||||
d.openSearch() // on the source the cursor is on: platform-prod
|
||||
d.openSearch()
|
||||
d.send(ctrl('s')) // only the source the cursor is on: platform-prod
|
||||
// Typing loads the scope: that source, without ctrl+a.
|
||||
d.typeText("smtp")
|
||||
if !strings.Contains(d.screen(), "platform-prod / kv-shared-prod / smtp-password") {
|
||||
@@ -76,10 +81,7 @@ func TestSearchLoadsAsYouType(t *testing.T) {
|
||||
}
|
||||
|
||||
// On All: everything.
|
||||
d.keys("tab") // to the scopes
|
||||
for d.m.search.src > 0 {
|
||||
d.send(tea.KeyPressMsg{Code: tea.KeyUp})
|
||||
}
|
||||
d.send(ctrl('s'))
|
||||
d.typeText("-")
|
||||
if _, ok := d.m.cache.containers[sourceRowKey("Azure", "sub-dev")]; !ok {
|
||||
t.Errorf("typing on All didn't load the other sources:\n%s", d.screen())
|
||||
@@ -183,19 +185,36 @@ func TestSearchStartsWhereYouAre(t *testing.T) {
|
||||
d.keys("2", "j") // platform-prod / kv-shared-prod
|
||||
d.openSearch()
|
||||
v := d.m.search
|
||||
if got := ansiStrip(v.scopes[v.src].label); !strings.Contains(got, "platform-prod") {
|
||||
t.Errorf("source not preselected: %q", got)
|
||||
scope := func() string { return ansiStrip(v.scopes[v.src].label) }
|
||||
if scope() != "All" {
|
||||
t.Errorf("opened on %q, want All", scope())
|
||||
}
|
||||
if v.res >= len(v.shown) || !strings.Contains(ansiStrip(v.shown[v.res].label), "kv-shared-prod") {
|
||||
t.Errorf("vault not under the cursor:\n%s", d.screen())
|
||||
}
|
||||
d.send(ctrl('s')) // narrows to the source, and back
|
||||
if !strings.Contains(scope(), "platform-prod") {
|
||||
t.Errorf("ctrl+s narrowed to %q", scope())
|
||||
}
|
||||
d.send(ctrl('s'))
|
||||
if scope() != "All" {
|
||||
t.Errorf("second ctrl+s on %q, want All", scope())
|
||||
}
|
||||
|
||||
// From the Sources pane: just the source.
|
||||
d.keys("esc", "esc", "1", "j") // stop typing, close; platform-dev
|
||||
// From Favourites: to Search, on All.
|
||||
d.keys("esc", "]", "]") // stop typing; Favourites
|
||||
d.send(ctrl('s'))
|
||||
if v.tab != tabSearch || scope() != "All" {
|
||||
t.Errorf("ctrl+s from another tab: tab %d, %q", v.tab, scope())
|
||||
}
|
||||
|
||||
// From the Sources pane: the source.
|
||||
d.keys("esc", "1", "j") // close; platform-dev
|
||||
d.openSearch()
|
||||
v = d.m.search
|
||||
if got := ansiStrip(v.scopes[v.src].label); !strings.Contains(got, "platform-dev") {
|
||||
t.Errorf("source not preselected: %q", got)
|
||||
d.send(ctrl('s'))
|
||||
if !strings.Contains(scope(), "platform-dev") {
|
||||
t.Errorf("ctrl+s narrowed to %q", scope())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,6 +258,24 @@ func TestGoToTabsAndModes(t *testing.T) {
|
||||
t.Errorf("[ → tab %d, want Search:\n%s", v.tab, d.screen())
|
||||
}
|
||||
|
||||
// g and G: top and bottom of the list with the cursor.
|
||||
d.keys("G")
|
||||
if v.res != len(v.shown)-1 || v.res == 0 {
|
||||
t.Errorf("G on results: %d of %d", v.res, len(v.shown))
|
||||
}
|
||||
d.keys("g")
|
||||
if v.res != 0 {
|
||||
t.Errorf("g on results: %d", v.res)
|
||||
}
|
||||
d.keys("h", "G")
|
||||
if v.src != len(v.scopes)-1 {
|
||||
t.Errorf("G on scopes: %d of %d", v.src, len(v.scopes))
|
||||
}
|
||||
d.keys("g", "l")
|
||||
if v.src != 0 {
|
||||
t.Errorf("g on scopes: %d", v.src)
|
||||
}
|
||||
|
||||
d.keys("/")
|
||||
d.typeText("shared")
|
||||
if !v.typing || len(v.shown) == 0 {
|
||||
|
||||
Reference in new issue
Block a user