Skip to main content

rope_split_block

Function rope_split_block 

Source
pub fn rope_split_block(
    store: &Store,
    current_block_id: EntityId,
    byte_offset_in_block: u32,
    new_block_id: EntityId,
)
Expand description

Split an existing block in the rope at byte_offset_in_block:

  • inserts a \n inter-block boundary at the absolute byte position block_start + byte_offset_in_block in the rope
  • shifts entries past that position by +1 byte
  • inserts a new entry for new_block_id at block_start + byte_offset_in_block + 1 (right after the newline), placed immediately after the original block in the entries Vec

byte_offset_in_block may be 0 (split before first char of block, i.e. insert empty block before this one) or equal to the block’s byte length (split after last char, i.e. insert empty block after).