fix: make clippy and fmt happy
@@ -1348,22 +1348,24 @@ fn run_edit_command(
let show_completion = match cmd {
EditCommand::DeleteBackward | EditCommand::DeleteForward => {
let start = match &deltas[0].0.els[0] {
- xi_rope::DeltaElement::Copy(_, end) => Some(end),
- _ => None,
+ xi_rope::DeltaElement::Copy(_, start) => start,
+ _ => &0,
};
let end = match &deltas[0].0.els[1] {
- xi_rope::DeltaElement::Copy(start, _) => Some(start),
- _ => None,
+ xi_rope::DeltaElement::Copy(end, _) => end,
+ _ => &0,
};
- if start.is_some() && end.is_some() {
- let slice = &doc_old[*start.unwrap()..*end.unwrap()];
- !slice.chars().all(|c| c.is_whitespace() || c.is_ascii_whitespace())
+ if start > &0 && end > &0 && end > start {
+ let slice = &doc_old[*start..*end];
+ !slice
+ .chars()
+ .all(|c| c.is_whitespace() || c.is_ascii_whitespace())
} else {
true
}
- },
+ }
EditCommand::InsertNewLine
| EditCommand::InsertTab
| EditCommand::NewLineAbove
