emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/evil-goggles 685e3714a5 090/225: Handle a specific u/redo


From: ELPA Syncer
Subject: [nongnu] elpa/evil-goggles 685e3714a5 090/225: Handle a specific u/redo case when the list has 2 connecting items
Date: Wed, 12 Jan 2022 08:58:58 -0500 (EST)

branch: elpa/evil-goggles
commit 685e3714a59016970428084aad52ba308009d646
Author: Evgeni Kolev <evgenysw@gmail.com>
Commit: Evgeni Kolev <evgenysw@gmail.com>

    Handle a specific u/redo case when the list has 2 connecting items
    
    This handles this scenario: `oinput<esc>u`
---
 evil-goggles.el | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/evil-goggles.el b/evil-goggles.el
index 58fed0b313..b111bfb731 100644
--- a/evil-goggles.el
+++ b/evil-goggles.el
@@ -270,8 +270,38 @@ N and LIST are the arguments of the original function."
   "Process LIST and return the first item if it's only one, or nil."
   (let* ((processed-list
           (cl-remove-if #'null (mapcar #'evil-goggles--undo-elt list))))
-    (when (eq 1 (length processed-list))
-      (car processed-list))))
+    (message "processed-list %s" processed-list)
+    (cond
+     ;; if there's only item in the list, return it
+     ((eq 1 (length processed-list))
+      (car processed-list))
+
+     ;; check if first and second region are connected:
+     ;; if we have: ((text-added 2 6) (text-added 1 2))
+     ;; then return: ((text-added 1 6))
+     ;;
+     ;; or, if we have: ((text-removed 1 2) (text-removed 2 6))
+     ;; then return: ((text-removed 1 6))
+     ;;
+     ;; TODO this could be more generic, it could work for any number of items 
in processed-list
+     ;; for example, this should be handled as well:
+     ;;    ((text-added 43 46) (text-added 22 43) (text-added 1 22))
+     ;; should become:
+     ;;    ((text-added 1 46))
+     ((and (eq 2 (length processed-list))
+           (eq (caadr processed-list) (caar processed-list)))
+      (let (
+            (change-type (caadr processed-list))
+            (start-of-first-region  (nth 1 (nth 0 processed-list)))
+            (end-of-first-region    (nth 2 (nth 0 processed-list)))
+            (start-of-second-region (nth 1 (nth 1 processed-list)))
+            (end-of-second-region   (nth 2 (nth 1 processed-list))))
+        (message "here1 %s %s" start-of-first-region end-of-second-region)
+        (cond
+         ((eq start-of-first-region end-of-second-region)
+          `(,change-type ,start-of-second-region ,end-of-first-region))
+         ((eq end-of-first-region start-of-second-region)
+          `(,change-type ,start-of-first-region ,end-of-second-region))))))))
 
 (defun evil-goggles--undo-elt (undo-elt)
   "Process UNDO-ELT.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]