summaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorJason Rodney Hansen2021-12-04 18:38:08 +0000
committerIvan Tham2021-12-05 08:22:58 +0000
commit461cd2056336c26138c96a4f0769f08d527be039 (patch)
treeeba09ac2005e3e01ef34a43af9a9ffbf07c6403e /helix-term/src/commands.rs
parent539c27e3f52a7c2744db7e92a45d7185eeeba917 (diff)
Small change
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs24
1 files changed, 11 insertions, 13 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 013a4280..3d583ba8 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -5800,28 +5800,26 @@ fn decrement(cx: &mut Context) {
fn increment_impl(cx: &mut Context, amount: i64) {
let (view, doc) = current!(cx.editor);
let selection = doc.selection(view.id);
- let text = doc.text();
+ let text = doc.text().slice(..);
- let changes = selection
+ let changes: Vec<_> = selection
.ranges()
.iter()
.filter_map(|range| {
- let incrementor: Box<dyn Increment> = if let Some(incrementor) =
- DateTimeIncrementor::from_range(text.slice(..), *range)
- {
- Box::new(incrementor)
- } else if let Some(incrementor) = NumberIncrementor::from_range(text.slice(..), *range)
- {
- Box::new(incrementor)
- } else {
- return None;
- };
+ let incrementor: Box<dyn Increment> =
+ if let Some(incrementor) = DateTimeIncrementor::from_range(text, *range) {
+ Box::new(incrementor)
+ } else if let Some(incrementor) = NumberIncrementor::from_range(text, *range) {
+ Box::new(incrementor)
+ } else {
+ return None;
+ };
let (range, new_text) = incrementor.increment(amount);
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.
// For example, if there are cursors on each of the year, month, and day of `2021-11-29`,