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 |
| 677 | 677 | ExitCurd(fmt.Errorf("Failed to select category")) |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | | if categorySelection.Key == "-1" { |
| 680 | if categorySelection.Key == "-1" || strings.EqualFold(categorySelection.Label, "Quit") { |
| 681 | 681 | ExitCurd(nil) |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | | if categorySelection.Key == "-2" { |
| 684 | if categorySelection.Key == "-2" || strings.EqualFold(categorySelection.Label, "Back") { |
| 685 | 685 | continue |
| 686 | 686 | } |
| 687 | 687 | |
internal/logic_regression_test.go
+15
| @@ -185,6 +185,21 @@ func TestVimKeysNormalModeNavigatesWithoutFiltering(t *testing.T) { |
| 185 | 185 | _ = model |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | func 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 | |
| 188 | 203 | func TestLegacyModeStillTypeToFilter(t *testing.T) { |
| 189 | 204 | prev := GetGlobalConfig() |
| 190 | 205 | SetGlobalConfig(&CurdConfig{VimKeys: false}) |
internal/selection_menu.go
+18 −13
| @@ -365,12 +365,16 @@ func (m *Model) filterOptions() { |
| 365 | 365 | }) |
| 366 | 366 | } |
| 367 | 367 | |
| 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 | } |
| 374 | 378 | backMatchesFilter := filterLower != "" && strings.Contains("back", filterLower) |
| 375 | 379 | |
| 376 | 380 | // If filter targets "back", pin it above Add new anime |
| @@ -378,19 +382,20 @@ func (m *Model) filterOptions() { |
| 378 | 382 | m.filteredKeys = append(m.filteredKeys, SelectionOption{Label: "Back", Key: "-2"}) |
| 379 | 383 | } |
| 380 | 384 | |
| 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") { |
| 384 | 387 | m.filteredKeys = append(m.filteredKeys, SelectionOption{Label: "Add new anime", Key: "add_new"}) |
| 385 | 388 | } |
| 386 | 389 | |
| 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") { |
| 389 | 392 | m.filteredKeys = append(m.filteredKeys, SelectionOption{Label: "Back", Key: "-2"}) |
| 390 | 393 | } |
| 391 | 394 | |
| 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 | } |
| 394 | 399 | } |
| 395 | 400 | |
| 396 | 401 | func detectHomeMenu(options []SelectionOption) bool { |
internal/update.go
+10 −1
| @@ -555,7 +555,16 @@ func HandlePendingUpdatePrompt(config *CurdConfig, currentVersion string) bool { |
| 555 | 555 | fmt.Println() |
| 556 | 556 | selected, err = DynamicSelectPreserveOrder(options) |
| 557 | 557 | } |
| 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 == "" { |
| 559 | 568 | return false |
| 560 | 569 | } |
| 561 | 570 | |