branch: elpa/evil-numbers
commit 31c7f1ad6dcc05f63284099819f06aa68653709c
Author: Jan Path <[email protected]>
Commit: Jan Path <[email protected]>
Fix wrong handling of region if number of characters changes
For example suppose we have the following where | is point and $ is mark and
execute evil-numbers/inc-at-point.
```
|9 9$
```
Expected:
```
10 10
```
Actual:
```
10 9
```
This is because we would save the beginning and end of the region before we
do
any changes, so the second 9 is pushed out of the saved region bounds by the
first 9 turning into a 10.
---
evil-numbers.el | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/evil-numbers.el b/evil-numbers.el
index 05dc0ba0e4..6d622f2c58 100644
--- a/evil-numbers.el
+++ b/evil-numbers.el
@@ -75,13 +75,11 @@ INCREMENTAL causes the first number to be increased by
1*amount, the second by
(cond
((and (not no-region) (region-active-p))
(let (deactivate-mark
- (rb (region-beginning))
- (re (region-end))
(count 1))
(save-excursion
(save-match-data
- (goto-char rb)
- (while (re-search-forward
"\\(?:0\\(?:[Bb][01]+\\|[Oo][0-7]+\\|[Xx][0-9A-Fa-f]+\\)\\|-?[0-9]+\\)" re t)
+ (if (< (mark) (point)) (exchange-point-and-mark))
+ (while (re-search-forward
"\\(?:0\\(?:[Bb][01]+\\|[Oo][0-7]+\\|[Xx][0-9A-Fa-f]+\\)\\|-?[0-9]+\\)"
(region-end) t)
(evil-numbers/inc-at-pt (* amount count) 'no-region)
(if incremental (setq count (+ count 1)))
;; Undo vim compatability.