diff --git a/crates/tui/src/app.rs b/crates/tui/src/app.rs index 68cf869..ff79d16 100644 --- a/crates/tui/src/app.rs +++ b/crates/tui/src/app.rs @@ -757,7 +757,7 @@ impl App { if forward { (p + 1) % colors.len() } else { - p.saturating_sub(1).min(colors.len() - 1) + if p == 0 { colors.len() - 1 } else { p - 1 } } } None => { @@ -1936,6 +1936,14 @@ plain text line app.handle_key(make_key(crossterm::event::KeyCode::Left)); assert_eq!(app.settings_draft.error, "red"); + + // backward wrap: red (index 0) → white (index 7) + app.handle_key(make_key(crossterm::event::KeyCode::Left)); + assert_eq!(app.settings_draft.error, "white"); + + // forward wrap: white (index 7) → red (index 0) + app.handle_key(make_key(crossterm::event::KeyCode::Right)); + assert_eq!(app.settings_draft.error, "red"); } #[test]