Skip to main content

addressable_inline_pieces

Function addressable_inline_pieces 

Source
pub fn addressable_inline_pieces(
    plain_text: &str,
    runs: &[FormatRun],
    anchors: &[BlockAnchor<'_>],
    base_char_offset: u32,
) -> Vec<AddressableInlinePiece>
Expand description

Build a block’s AddressableInlinePieces from its plain_text, format runs, and anchors, offset by base_char_offset — the character position this block’s own first piece should start at.

Layered on merge_runs_and_anchors rather than duplicating its weave: the only thing added here is the byte→char conversion (plain_text[start..end].chars().count() is the only correct way to size a UTF-8 slice in the character space every other offset in this crate uses — NOT end - start, which is a byte count) and a running base_char_offset accumulator. Pass 0 to get offsets relative to this block alone, which is what this module’s own tests do; crate::format_runs_query::addressable_inline_pieces_for_block passes the block’s own document_position instead, to land in document-wide space.