diff --git a/local/recipes/tui/tlc/source/src/viewer/mod.rs b/local/recipes/tui/tlc/source/src/viewer/mod.rs index aaf8b45cd0..b82ce61ab8 100644 --- a/local/recipes/tui/tlc/source/src/viewer/mod.rs +++ b/local/recipes/tui/tlc/source/src/viewer/mod.rs @@ -2025,6 +2025,39 @@ mod tests { assert_eq!(n, 2); // only standalone "foo" entries } + + + #[test] + fn search_opposite_shift_n_inverts_direction() { + let p = make_text("opp.txt", b"foo bar foo baz foo"); + let mut v = Viewer::open(&p).unwrap(); + v.search("foo", false).unwrap(); + // n moves forward to second match. + let m = v.search_next(); + assert!(m.is_some()); + // Shift-N should move backward to first match. + let shift_n = Key { code: b'N' as u32, mods: crate::key::Modifiers::SHIFT }; + v.handle_key(shift_n); + // After Shift-N, n should move forward again (direction flipped back). + let m2 = v.search_next(); + assert!(m2.is_some()); + } + + #[test] + fn bookmarks_wraps_marker() { + let p = make_text("wrapm.txt", b"a\nb\n"); + let mut v = Viewer::open(&p).unwrap(); + // Press m 10 times — each sets a bookmark at top=0 then advances. + for _ in 0..10 { + v.handle_key(k('m')); + } + // After 10 presses, marker should have wrapped back to 0. + assert_eq!(v.marker, 0); + // The r key jumps to marker-1 = 9 (which was set in the 10th press). + v.top = 99; + v.handle_key(k('r')); + assert_eq!(v.top, 0, "jump to slot 9 which has the bookmark at position 0"); + } fn k(c: char) -> Key { Key { code: c as u32, mods: crate::key::Modifiers::empty() } }