Improve safety of Cursor::selection
This commit is contained in:
parent
855c0faa59
commit
a1210c9dae
3 changed files with 14 additions and 20 deletions
|
|
@ -166,8 +166,8 @@ impl Cursor {
|
|||
end.min(value.len())
|
||||
}
|
||||
|
||||
pub(crate) fn selection(&self) -> Option<(usize, usize)> {
|
||||
match self.state {
|
||||
pub(crate) fn selection(&self, value: &Value) -> Option<(usize, usize)> {
|
||||
match self.state(value) {
|
||||
State::Selection { start, end } => {
|
||||
Some((start.min(end), start.max(end)))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue