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

Method insert_str

src/editor/buffer.rs:155–177  ·  view source on GitHub ↗
(&mut self, text: &str)

Source from the content-addressed store, hash-verified

153 }
154
155 pub fn insert_str(&mut self, text: &str) {
156 if text.is_empty() {
157 return;
158 }
159 let cursor_before = self.cursor;
160 let (start, deleted) = self.take_selection();
161 let char_idx = start.unwrap_or_else(|| self.cursor_char_idx());
162 if let Some(start) = start {
163 self.cursor = self.cursor.set_position_from_char(start, &self.document);
164 }
165
166 self.document.insert_str(char_idx, text);
167 self.cursor = self
168 .cursor
169 .set_position_from_char(char_idx + text.chars().count(), &self.document);
170
171 self.push_undo(UndoRecord {
172 start: char_idx,
173 inserted: text.to_owned(),
174 deleted,
175 cursor_before,
176 });
177 }
178
179 pub fn insert_line(&mut self, line: usize, text: &str) {
180 let cursor_before = self.cursor;

Callers 4

undoMethod · 0.45
redoMethod · 0.45
handle_editor_keyMethod · 0.45
apply_editor_keyFunction · 0.45

Calls 5

is_emptyMethod · 0.80
take_selectionMethod · 0.80
cursor_char_idxMethod · 0.80
push_undoMethod · 0.80

Tested by

no test coverage detected