Small change

imgbot
Jason Rodney Hansen 3 years ago committed by Ivan Tham
parent 539c27e3f5
commit 461cd20563

@ -5800,18 +5800,16 @@ fn decrement(cx: &mut Context) {
fn increment_impl(cx: &mut Context, amount: i64) { fn increment_impl(cx: &mut Context, amount: i64) {
let (view, doc) = current!(cx.editor); let (view, doc) = current!(cx.editor);
let selection = doc.selection(view.id); let selection = doc.selection(view.id);
let text = doc.text(); let text = doc.text().slice(..);
let changes = selection let changes: Vec<_> = selection
.ranges() .ranges()
.iter() .iter()
.filter_map(|range| { .filter_map(|range| {
let incrementor: Box<dyn Increment> = if let Some(incrementor) = let incrementor: Box<dyn Increment> =
DateTimeIncrementor::from_range(text.slice(..), *range) if let Some(incrementor) = DateTimeIncrementor::from_range(text, *range) {
{
Box::new(incrementor) Box::new(incrementor)
} else if let Some(incrementor) = NumberIncrementor::from_range(text.slice(..), *range) } else if let Some(incrementor) = NumberIncrementor::from_range(text, *range) {
{
Box::new(incrementor) Box::new(incrementor)
} else { } else {
return None; return None;
@ -5821,7 +5819,7 @@ fn increment_impl(cx: &mut Context, amount: i64) {
Some((range.from(), range.to(), Some(new_text))) Some((range.from(), range.to(), Some(new_text)))
}) })
.collect::<Vec<_>>(); .collect();
// Overlapping changes in a transaction will panic, so we need to find and remove them. // Overlapping changes in a transaction will panic, so we need to find and remove them.
// For example, if there are cursors on each of the year, month, and day of `2021-11-29`, // For example, if there are cursors on each of the year, month, and day of `2021-11-29`,

Loading…
Cancel
Save