nomad / crop

🌾 A pretty fast text rope
https://crates.io/crates/crop
MIT License
261 stars 13 forks source link

Way to insert by line and column? #18

Closed jcs090218 closed 2 months ago

jcs090218 commented 2 months ago

Is there way to insert bytes by line and column?

noib3 commented 2 months ago

Not directly, but you can convert a (line, col) pair into a byte offset like this:

let mut rope: Rope = todo!();
let line: usize = todo!();
let col: usize = todo!(); 
let byte_offset = rope.byte_of_line(line) + col;
rope.insert(byte_offset, "");