diff options
author | Jason Rodney Hansen | 2021-11-16 02:51:10 +0000 |
---|---|---|
committer | Ivan Tham | 2021-12-05 08:22:58 +0000 |
commit | c1f6167e37909517676c30b0a80203739e8492a5 (patch) | |
tree | 1b62c2c132ff1dfdc2c563ffb2a23bd6d42de60f /helix-term | |
parent | 11a2f9ac31fad51bfcd6cfdaa4ad43e8430595ce (diff) |
Add support for dates for increment/decrement
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/commands.rs | 28 |
1 files changed, 20 insertions, 8 deletions
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 { |