pub fn char_to_line_idx(text: &str, char_idx: usize) -> usize
Expand description

Converts from char-index to line-index in a string slice.

This is equivalent to counting the line endings before the given char.

Any past-the-end index will return the last line index.

Runs in O(N) time.