rho-coding-agent 3.11.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
use std::sync::Arc;

use pretty_assertions::assert_eq;
use ratatui::{
    buffer::{Buffer, CellDiffOption},
    layout::Rect,
    style::Style,
};

use super::PaintedLinks;
use crate::tui::{synced_backend::ScreenLink, text_links::RowLink};

/// A link keeps only the cells still showing the text it was painted over:
/// an overlay drawn across its middle splits it, and the kept cells are
/// written every frame so the link follows them.
#[test]
fn overlays_drawn_after_a_link_cut_it() {
    let area = Rect::new(2, 1, 20, 3);
    let mut buffer = Buffer::empty(Rect::new(0, 0, 24, 5));
    buffer.set_string(3, 2, "src/main.rs", Style::default());
    let url: Arc<str> = "file://h/w/src/main.rs".into();
    let mut painted = PaintedLinks::default();
    painted.record(
        &buffer,
        area,
        vec![RowLink {
            row: 1,
            columns: 1..12,
            url: Arc::clone(&url),
        }],
    );

    // An overlay chip covers "/ma".
    buffer.set_string(6, 2, "^^^", Style::default());
    let links = painted.finish(&mut buffer);

    let link = |x| ScreenLink {
        y: 2,
        x,
        url: Arc::clone(&url),
    };
    assert_eq!(links, vec![link(3..6), link(9..14)]);
    assert_eq!(buffer[(3, 2)].diff_option, CellDiffOption::AlwaysUpdate);
    assert_eq!(buffer[(6, 2)].diff_option, CellDiffOption::None);
}