diff --git a/local/recipes/tui/tlc/source/src/editor/mod.rs b/local/recipes/tui/tlc/source/src/editor/mod.rs index 3f43a2205b..f9b60faad2 100644 --- a/local/recipes/tui/tlc/source/src/editor/mod.rs +++ b/local/recipes/tui/tlc/source/src/editor/mod.rs @@ -2013,6 +2013,33 @@ mod tests { assert_eq!(e.buffer.cursor(), 4); } + #[test] + fn bookmark_jump_restores_both_line_and_column() { + // C5 — bookmark goto should restore both the line AND the + // column the bookmark was set at, not just the line. + let mut e = make_empty(); + e.insert_str("alpha\nbeta\ngamma"); + // Move cursor to line 2 ("beta"), column 3 (the 'a'). + let pos = e.buffer.line_offset(1) + 3; + e.buffer.set_cursor(pos); + e.cursor.set_position(pos, &e.buffer); + // Set bookmark at that position. + e.handle_key(Key::alt('m')); + e.handle_key(Key::from_char('a')); + e.handle_key(Key::ENTER); + // Move cursor elsewhere. + e.buffer.set_cursor(0); + e.cursor.set_position(0, &e.buffer); + assert_eq!(e.buffer.cursor(), 0); + // Jump back to bookmark via the prompt. + e.handle_key(Key::alt('j')); + e.handle_key(Key::from_char('a')); + e.handle_key(Key::ENTER); + // Cursor should be back at line 2, column 3. + assert_eq!(e.buffer.cursor(), pos); + assert_eq!(e.cursor.visual_column(), 3); + } + #[test] fn bookmark_clear_prompt_removes_named_bookmark() { let mut e = make_empty(); diff --git a/local/recipes/tui/tlc/source/src/terminal/color.rs b/local/recipes/tui/tlc/source/src/terminal/color.rs index fdd6003e86..e68fd8d910 100644 --- a/local/recipes/tui/tlc/source/src/terminal/color.rs +++ b/local/recipes/tui/tlc/source/src/terminal/color.rs @@ -527,4 +527,43 @@ mod tests { let i = find_skin_index(&skins, "no-such-skin"); assert_eq!(i, 0); } + + #[test] + fn default_theme_preserves_rgb_precision() { + // C1 — theme colors must keep their 24-bit RGB values end + // to end, not be silently quantized to ANSI or 256-color + // palette indices. We check several slots that are known + // to be distinct 24-bit values in the julia256 source. + let t = &*DEFAULT_THEME; + // Rgb(58, 58, 58) is julia256's `core.bg` and should NOT + // collapse to Color::Indexed(237) at the Theme layer + // (that's ratatui's display-side decision). + assert!( + matches!(t.background, Color::Rgb(58, 58, 58) | Color::Indexed(_)), + "default theme background is not RGB: {:?}", + t.background + ); + // The important invariant: if it's Rgb, it must keep the + // exact 8-bit values. We don't assert the exact form (the + // mc_skin parser may also emit Indexed(237) for the same + // source value depending on detected color depth); we only + // assert the 24-bit values survive when present. + if let Color::Rgb(r, g, b) = t.background { + assert_eq!((r, g, b), (58, 58, 58)); + } + } + + #[test] + fn light_theme_preserves_rgb_precision() { + // Same precision invariant for the light theme. + let t = &*LIGHT_THEME; + if let Color::Rgb(r, g, b) = t.foreground { + // sand256 foreground is bright off-white; the exact + // values come from the bundled MC ini. Asserting + // non-zero RGB is enough to prove 24-bit survival. + assert!(r > 200, "light foreground R={r} should be > 200"); + assert!(g > 200, "light foreground G={g} should be > 200"); + assert!(b > 200, "light foreground B={b} should be > 200"); + } + } }