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::style::Style;

use super::{place_on_row, text_links, LinkedRun, RowLink, TextLink};

/// A link's runs merge into one byte range, and a link wrapped onto two
/// rows is placed on each in that row's display columns.
#[test]
fn links_merge_runs_and_split_across_rows() {
    let url: Arc<str> = "file:///w/src/a.rs".into();
    let style = Style::default();
    let runs = [
        LinkedRun::plain("see ", style),
        LinkedRun::linked("src/", style, Arc::clone(&url)),
        LinkedRun::linked("a.rs", style, Arc::clone(&url)),
        LinkedRun::linked(":4", style, Arc::clone(&url)),
        LinkedRun::plain(" now", style),
    ];
    let links = text_links(&runs);
    assert_eq!(
        links,
        vec![TextLink {
            bytes: 4..14,
            url: Arc::clone(&url),
        }]
    );

    let text = "see src/a.rs:4 now";
    let mut placed = Vec::new();
    // Row 0 shows "see src/", row 1 "a.rs:4 now" after a two-column indent.
    place_on_row(&links, text, 0..8, 0, 0, &mut placed);
    place_on_row(&links, text, 8..18, 1, 2, &mut placed);
    assert_eq!(
        placed,
        vec![
            RowLink {
                row: 0,
                columns: 4..8,
                url: Arc::clone(&url),
            },
            RowLink {
                row: 1,
                columns: 2..8,
                url,
            },
        ]
    );
}