Returns (logical_line, col_in_line, char_offset_of_line_start)
(&self)
| 117 | |
| 118 | /// Returns (logical_line, col_in_line, char_offset_of_line_start) |
| 119 | pub fn cursor_line_col(&self) -> (usize, usize, usize) { |
| 120 | let mut line = 0; |
| 121 | let mut line_start = 0usize; |
| 122 | for (i, ch) in self.input.chars().enumerate() { |
| 123 | if i == self.cursor { |
| 124 | return (line, self.cursor - line_start, line_start); |
| 125 | } |
| 126 | if ch == '\n' { |
| 127 | line += 1; |
| 128 | line_start = i + 1; |
| 129 | } |
| 130 | } |
| 131 | (line, self.cursor - line_start, line_start) |
| 132 | } |
| 133 | |
| 134 | fn input_line_char_counts(&self) -> Vec<usize> { |
| 135 | self.input.split('\n').map(|l| l.chars().count()).collect() |
no outgoing calls
no test coverage detected