MCPcopy Create free account
hub / github.com/Eeive/Evcode-ide / position_to_char

Method position_to_char

src/editor/document.rs:95–106  ·  view source on GitHub ↗
(&self, line: usize, column: usize)

Source from the content-addressed store, hash-verified

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());

Callers 3

selected_textMethod · 0.80
take_selectionMethod · 0.80
cursor_char_idxMethod · 0.80

Calls 2

line_to_charMethod · 0.80
line_textMethod · 0.45

Tested by

no test coverage detected