aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/increment/mod.rs
diff options
context:
space:
mode:
authorgreg-enbala2023-01-16 16:15:23 +0000
committerGitHub2023-01-16 16:15:23 +0000
commit60f84be40c1c488dacf823f791ca33f43b5d28d8 (patch)
tree0efb36c23780c8be4e5e7f6d26675da93091ec16 /helix-core/src/increment/mod.rs
parent97083f88364e1455f42023dadadfb410fd476505 (diff)
Separate jump behavior from increment/decrement (#4123)
increment/decrement (C-a/C-x) had some buggy behavior where selections could be offset incorrectly or the editor could panic with some edits that changed the number of characters in a number or date. These stemmed from the automatic jumping behavior which attempted to find the next date or integer to increment. The jumping behavior also complicated the code quite a bit and made the behavior somewhat difficult to predict when using many cursors. This change removes the automatic jumping behavior and only increments or decrements when the full text in a range of a selection is a number or date. This simplifies the code and fixes the panics and buggy behaviors from changing the number of characters.
Diffstat (limited to 'helix-core/src/increment/mod.rs')
-rw-r--r--helix-core/src/increment/mod.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/helix-core/src/increment/mod.rs b/helix-core/src/increment/mod.rs
index f5945774..f1978bde 100644
--- a/helix-core/src/increment/mod.rs
+++ b/helix-core/src/increment/mod.rs
@@ -1,8 +1,10 @@
-pub mod date_time;
-pub mod number;
+mod date_time;
+mod integer;
-use crate::{Range, Tendril};
+pub fn integer(selected_text: &str, amount: i64) -> Option<String> {
+ integer::increment(selected_text, amount)
+}
-pub trait Increment {
- fn increment(&self, amount: i64) -> (Range, Tendril);
+pub fn date_time(selected_text: &str, amount: i64) -> Option<String> {
+ date_time::increment(selected_text, amount)
}