From c1f6167e37909517676c30b0a80203739e8492a5 Mon Sep 17 00:00:00 2001 From: Jason Rodney Hansen Date: Mon, 15 Nov 2021 19:51:10 -0700 Subject: Add support for dates for increment/decrement --- helix-term/src/commands.rs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'helix-term') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 99d1432c..639bbd83 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1,5 +1,7 @@ use helix_core::{ - comment, coords_at_pos, find_first_non_whitespace_char, find_root, graphemes, + comment, coords_at_pos, + date::DateIncrementor, + find_first_non_whitespace_char, find_root, graphemes, history::UndoKind, indent, indent::IndentStyle, @@ -5802,13 +5804,23 @@ fn increment_impl(cx: &mut Context, amount: i64) { let text = doc.text(); let changes = selection.ranges().iter().filter_map(|range| { - let incrementor = NumberIncrementor::from_range(text.slice(..), *range)?; - let new_text = incrementor.incremented_text(amount); - Some(( - incrementor.range.from(), - incrementor.range.to(), - Some(new_text), - )) + if let Some(incrementor) = DateIncrementor::from_range(text.slice(..), *range) { + let new_text = incrementor.incremented_text(amount); + Some(( + incrementor.range.from(), + incrementor.range.to(), + Some(new_text), + )) + } else if let Some(incrementor) = NumberIncrementor::from_range(text.slice(..), *range) { + let new_text = incrementor.incremented_text(amount); + Some(( + incrementor.range.from(), + incrementor.range.to(), + Some(new_text), + )) + } else { + None + } }); if changes.clone().count() > 0 { -- cgit v1.2.3-70-g09d2