Returns the ordered selection range `(start, end)` if a selection is active.
(&self)
| 85 | impl TextEditState { |
| 86 | /// Returns the ordered selection range `(start, end)` if a selection is active. |
| 87 | pub fn selection_range(&self) -> Option<(usize, usize)> { |
| 88 | self.selection_anchor.map(|anchor| { |
| 89 | let start = anchor.min(self.cursor_pos); |
| 90 | let end = anchor.max(self.cursor_pos); |
| 91 | (start, end) |
| 92 | }) |
| 93 | } |
| 94 | |
| 95 | /// Returns the selected text, or empty string if no selection. |
| 96 | pub fn selected_text(&self) -> &str { |
no outgoing calls
no test coverage detected