Skip to main content

block_char_length

Function block_char_length 

Source
pub fn block_char_length(block: &Block, store: &Store) -> i64
Expand description

Logical character count of a block — what the old Block.text_length field used to cache. Image anchors are stored as \u{FFFC} (one char, three bytes) inside the rope content, so the char count already covers them. Returns 0 for blocks not registered in the offset index.

O(log n) via ropey::Rope::byte_to_char — does NOT materialize the block’s text into a String. Replaces the prior O(L) implementation that counted chars by walking UTF-8 over a cloned slice.