(&self, line: usize, column: usize)
| 93 | } |
| 94 | |
| 95 | pub fn position_to_char(&self, line: usize, column: usize) -> usize { |
| 96 | let line_start = self.line_to_char(line); |
| 97 | let Some(text) = self.line_text(line) else { |
| 98 | return line_start; |
| 99 | }; |
| 100 | let char_offset = text |
| 101 | .graphemes(true) |
| 102 | .take(column) |
| 103 | .map(|g| g.chars().count()) |
| 104 | .sum::<usize>(); |
| 105 | line_start + char_offset |
| 106 | } |
| 107 | |
| 108 | pub fn previous_grapheme_boundary(&self, char_idx: usize) -> usize { |
| 109 | let char_idx = char_idx.min(self.len_chars()); |
no test coverage detected