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

Method take_selection

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

Source from the content-addressed store, hash-verified

358 }
359
360 fn take_selection(&mut self) -> (Option<usize>, String) {
361 let Some((start, end)) = self.selection_range() else {
362 return (None, String::new());
363 };
364 let start_idx = self.document.position_to_char(start.0, start.1);
365 let end_idx = self.document.position_to_char(end.0, end.1);
366 let deleted = self.document.slice_text(start_idx, end_idx);
367 self.document.remove_char_range(start_idx, end_idx);
368 self.cursor = self.cursor.set(start.0, start.1, &self.document);
369 self.selection_anchor = None;
370 (Some(start_idx), deleted)
371 }
372
373 fn cursor_char_idx(&self) -> usize {
374 self.document

Callers 3

insert_charMethod · 0.80
insert_strMethod · 0.80
delete_selectionMethod · 0.80

Calls 5

selection_rangeMethod · 0.80
position_to_charMethod · 0.80
slice_textMethod · 0.80
remove_char_rangeMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected