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

Method redo

src/editor/buffer.rs:317–344  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

315 }
316
317 pub fn redo(&mut self) -> bool {
318 let Some(record) = self.redo_stack.pop_back() else {
319 return false;
320 };
321
322 let deleted_len = record.deleted.chars().count();
323 if deleted_len > 0 {
324 self.document
325 .remove_char_range(record.start, record.start + deleted_len);
326 }
327 if !record.inserted.is_empty() {
328 self.document.insert_str(record.start, &record.inserted);
329 }
330
331 let cursor_after = record.start + record.inserted.chars().count();
332 self.cursor = self
333 .cursor
334 .set_position_from_char(cursor_after, &self.document);
335 self.cursor.clamp_to_document(&self.document);
336 self.selection_anchor = None;
337
338 self.undo_stack.push_back(record);
339 if self.undo_stack.len() > MAX_UNDO {
340 self.undo_stack.pop_front();
341 }
342
343 true
344 }
345
346 fn delete_selection(&mut self) -> bool {
347 let cursor_before = self.cursor;

Callers

nothing calls this directly

Calls 5

remove_char_rangeMethod · 0.80
is_emptyMethod · 0.80
clamp_to_documentMethod · 0.80
insert_strMethod · 0.45

Tested by

no test coverage detected