Commit 21baf6f4e0
Unsigned
Layout: unified · split
internal/curd.go +13 −1
| @@ -1365,7 +1365,7 @@ func NextEpisodePrompt(userCurdConfig *CurdConfig) { | ||
| 1365 | 1365 | // Create options for the selection |
| 1366 | 1366 | options := []SelectionOption{ |
| 1367 | 1367 | {Key: "yes", Label: "Yes, start next episode"}, |
| 1368 | // "no": "No, quit", | |
| 1368 | // {Key: "-1", Label: "No, quit"}, | |
| 1369 | 1369 | } |
| 1370 | 1370 | |
| 1371 | 1371 | // Use DynamicSelect for both CLI and Rofi modes |
| @@ -1375,6 +1375,8 @@ func NextEpisodePrompt(userCurdConfig *CurdConfig) { | ||
| 1375 | 1375 | ExitCurd(err) |
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | Log(fmt.Sprintf("User Selected Key: '%s', Label: '%s'", selectedOption.Key, selectedOption.Label)) | |
| 1379 | ||
| 1378 | 1380 | if selectedOption.Key == "-1" { |
| 1379 | 1381 | // User selected to quit |
| 1380 | 1382 | fmt.Print("\r\033[K") // Carriage return and clear line |
| @@ -1384,6 +1386,16 @@ func NextEpisodePrompt(userCurdConfig *CurdConfig) { | ||
| 1384 | 1386 | return |
| 1385 | 1387 | } |
| 1386 | 1388 | |
| 1389 | if selectedOption.Key != "yes" { | |
| 1390 | // User selected something other than yes (shouldn't happen, but safety check) | |
| 1391 | Log(fmt.Sprintf("Unexpected selection key: %s", selectedOption.Key)) | |
| 1392 | fmt.Print("\r\033[K") // Carriage return and clear line | |
| 1393 | ExitMPV(anime.Ep.Player.SocketPath) | |
| 1394 | CurdOut("Exiting without starting next episode") | |
| 1395 | ExitCurd(nil) | |
| 1396 | return | |
| 1397 | } | |
| 1398 | ||
| 1387 | 1399 | // If yes, start the next episode |
| 1388 | 1400 | prevEpisode := anime.Ep.Number |
| 1389 | 1401 | anime.Ep.Number++ |
internal/selection_menu.go +7 −3
| @@ -81,9 +81,8 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | ||
| 81 | 81 | case tea.KeyMsg: |
| 82 | 82 | switch msg.String() { |
| 83 | 83 | case "ctrl+c": |
| 84 | // Return quit selection option instead of quitting the program | |
| 85 | m.filteredKeys[m.selected] = SelectionOption{"quit", "-1"} | |
| 86 | return m, tea.Quit // Properly exit the program | |
| 84 | // Return quit selection option directly | |
| 85 | return m, tea.Quit | |
| 87 | 86 | case "backspace": |
| 88 | 87 | if len(m.filter) > 0 { |
| 89 | 88 | m.filter = m.filter[:len(m.filter)-1] |
| @@ -463,6 +462,11 @@ func DynamicSelect(options []SelectionOption) (SelectionOption, error) { | ||
| 463 | 462 | return SelectionOption{}, fmt.Errorf("unexpected model type") |
| 464 | 463 | } |
| 465 | 464 | |
| 465 | // Check if the program was quit with Ctrl+C | |
| 466 | if err != nil { | |
| 467 | return SelectionOption{Key: "-1", Label: "Quit"}, nil | |
| 468 | } | |
| 469 | ||
| 466 | 470 | if finalSelectionModel.selected < len(finalSelectionModel.filteredKeys) { |
| 467 | 471 | return finalSelectionModel.filteredKeys[finalSelectionModel.selected], nil |
| 468 | 472 | } |