branch: externals/shift-number
commit e9c928e94f71514629c60ad5662e8c8f21594a02
Author: Campbell Barton <[email protected]>
Commit: Campbell Barton <[email protected]>
Cleanup: skip calls to delete/insert for empty regions
---
shift-number.el | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/shift-number.el b/shift-number.el
index 21d0d55e35..d507d526ad 100644
--- a/shift-number.el
+++ b/shift-number.el
@@ -97,8 +97,12 @@ Return the region replaced."
(setq str (substring str (or i-beg 0) (or i-end len))))
(goto-char beg)
- (delete-region beg end)
- (insert str)
+
+ (unless (eq beg end)
+ (delete-region beg end))
+ (unless (string-empty-p str)
+ (insert str))
+
(when i-end-ofs
;; Leave the cursor where it would be if the end wasn't clipped.
(goto-char (+ (point) i-end-ofs)))