MCPcopy Create free account
hub / github.com/TheRedDeveloper/ply-engine / delete_selection

Method delete_selection

src/text_input.rs:108–119  ·  view source on GitHub ↗

Delete the current selection and place cursor at the start. Returns true if a selection was deleted.

(&mut self)

Source from the content-addressed store, hash-verified

106 /// Delete the current selection and place cursor at the start.
107 /// Returns true if a selection was deleted.
108 pub fn delete_selection(&mut self) -> bool {
109 if let Some((start, end)) = self.selection_range() {
110 let byte_start = char_index_to_byte(&self.text, start);
111 let byte_end = char_index_to_byte(&self.text, end);
112 self.text.drain(byte_start..byte_end);
113 self.cursor_pos = start;
114 self.selection_anchor = None;
115 true
116 } else {
117 false
118 }
119 }
120
121 /// Insert text at the current cursor position, replacing any selection.
122 /// Respects max_length if provided.

Callers 7

insert_textMethod · 0.80
backspaceMethod · 0.80
delete_forwardMethod · 0.80
backspace_wordMethod · 0.80
delete_word_forwardMethod · 0.80
test_selection_deleteFunction · 0.80

Calls 2

char_index_to_byteFunction · 0.85
selection_rangeMethod · 0.80

Tested by 1

test_selection_deleteFunction · 0.64