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

Method selected_text

src/text_input.rs:96–104  ·  view source on GitHub ↗

Returns the selected text, or empty string if no selection.

(&self)

Source from the content-addressed store, hash-verified

94
95 /// Returns the selected text, or empty string if no selection.
96 pub fn selected_text(&self) -> &str {
97 if let Some((start, end)) = self.selection_range() {
98 let byte_start = char_index_to_byte(&self.text, start);
99 let byte_end = char_index_to_byte(&self.text, end);
100 &self.text[byte_start..byte_end]
101 } else {
102 ""
103 }
104 }
105
106 /// Delete the current selection and place cursor at the start.
107 /// Returns true if a selection was deleted.

Callers 1

beginMethod · 0.80

Calls 2

char_index_to_byteFunction · 0.85
selection_rangeMethod · 0.80

Tested by

no test coverage detected