Commit d9152af709

d9152af7093cfbec741271e80f8a5f4089d642cd

parent: 3093fb71c3

Unsigned

Wraient <wraient.911@gmail.com> · 2026-07-22 20:51 UTC

Fix: Quit actually exits; filter /quit only shows Quit

Pinned Back/Quit now respect the search filter so /quit does not leave
Back selected first. Choosing Quit on the update prompt exits the app
instead of continuing into the main menu.

Layout: unified · split

internal/curd.go +2 −2
@@ -677,11 +677,11 @@ func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAni
677677 ExitCurd(fmt.Errorf("Failed to select category"))
678678 }
679679
680 if categorySelection.Key == "-1" {
680 if categorySelection.Key == "-1" || strings.EqualFold(categorySelection.Label, "Quit") {
681681 ExitCurd(nil)
682682 }
683683
684 if categorySelection.Key == "-2" {
684 if categorySelection.Key == "-2" || strings.EqualFold(categorySelection.Label, "Back") {
685685 continue
686686 }
687687
internal/logic_regression_test.go +15
@@ -185,6 +185,21 @@ func TestVimKeysNormalModeNavigatesWithoutFiltering(t *testing.T) {
185185 _ = model
186186}
187187
188func TestFilterQuitOnlyShowsQuitNotBack(t *testing.T) {
189 model := &Model{
190 allOptions: []SelectionOption{
191 {Key: "CURRENT", Label: "Currently Watching"},
192 {Key: "ALL", Label: "Show All"},
193 },
194 isHomeMenu: false, // action-style menu that has Back
195 filter: "quit",
196 }
197 model.filterOptions()
198 if len(model.filteredKeys) != 1 || model.filteredKeys[0].Key != "-1" {
199 t.Fatalf("filter 'quit' should only pin Quit, got %#v", model.filteredKeys)
200 }
201}
202
188203func TestLegacyModeStillTypeToFilter(t *testing.T) {
189204 prev := GetGlobalConfig()
190205 SetGlobalConfig(&CurdConfig{VimKeys: false})
internal/selection_menu.go +18 −13
@@ -365,12 +365,16 @@ func (m *Model) filterOptions() {
365365 })
366366 }
367367
368 // Determine whether the current filter is a substring of the pinned labels.
369 // When the filter matches "back" (e.g. "b", "ba", "bac", "back"), Back should
370 // appear BEFORE "Add new anime" so it is easy to reach. Otherwise keep the
371 // default order: Add new anime → Back → Quit.
372 // All three pinned items are always shown regardless of filter text.
373 filterLower := strings.ToLower(m.filter)
368 // Pin Back / Add new / Quit only when the filter is empty or matches their labels.
369 // Previously Quit/Back were always forced visible, so "/quit" still showed Back first
370 // and Enter could select the wrong row.
371 filterLower := strings.ToLower(strings.TrimSpace(m.filter))
372 pinMatches := func(label string) bool {
373 if filterLower == "" {
374 return true
375 }
376 return strings.Contains(strings.ToLower(label), filterLower)
377 }
374378 backMatchesFilter := filterLower != "" && strings.Contains("back", filterLower)
375379
376380 // If filter targets "back", pin it above Add new anime
@@ -378,19 +382,20 @@ func (m *Model) filterOptions() {
378382 m.filteredKeys = append(m.filteredKeys, SelectionOption{Label: "Back", Key: "-2"})
379383 }
380384
381 // Add new anime is always shown (pinned)
382 if m.addNewOption {
383
385 // Add new anime when unfiltered or filter matches
386 if m.addNewOption && pinMatches("Add new anime") {
384387 m.filteredKeys = append(m.filteredKeys, SelectionOption{Label: "Add new anime", Key: "add_new"})
385388 }
386389
387 // Back in its default position (after Add new anime) when filter doesn't target it
388 if !m.isHomeMenu && !backMatchesFilter {
390 // Back in its default position when unfiltered (or filter matches "back" handled above)
391 if !m.isHomeMenu && !backMatchesFilter && pinMatches("Back") {
389392 m.filteredKeys = append(m.filteredKeys, SelectionOption{Label: "Back", Key: "-2"})
390393 }
391394
392 // Quit is always last
393 m.filteredKeys = append(m.filteredKeys, SelectionOption{Label: "Quit", Key: "-1"})
395 // Quit last — only when unfiltered or filter matches "quit"
396 if pinMatches("Quit") {
397 m.filteredKeys = append(m.filteredKeys, SelectionOption{Label: "Quit", Key: "-1"})
398 }
394399}
395400
396401func detectHomeMenu(options []SelectionOption) bool {
internal/update.go +10 −1
@@ -555,7 +555,16 @@ func HandlePendingUpdatePrompt(config *CurdConfig, currentVersion string) bool {
555555 fmt.Println()
556556 selected, err = DynamicSelectPreserveOrder(options)
557557 }
558 if err != nil || selected.Key == "-1" || selected.Key == "-2" || selected.Key == "continue" || selected.Key == "" {
558 if err != nil {
559 return false
560 }
561 // Quit from the pinned menu must exit the whole program (not fall through to curd).
562 if selected.Key == "-1" || strings.EqualFold(selected.Label, "Quit") {
563 ExitCurd(nil)
564 return true
565 }
566 // Back / empty = dismiss update prompt and continue the session.
567 if selected.Key == "-2" || selected.Key == "continue" || selected.Key == "" {
559568 return false
560569 }
561570