Commits

Frank Fischer committed 802056f

Ensure :global generates a single undo step

Comments (0)

Files changed (2)

     (error "No pattern given"))
   (unless command
     (error "No command given"))
-  (let ((case-fold-search
-         (eq (evil-ex-regex-case pattern 'smart) 'insensitive))
-        match markers)
-    (when (and pattern command)
-      (setq isearch-string pattern)
-      (isearch-update-ring pattern t)
-      (goto-char beg)
-      (evil-move-beginning-of-line)
-      (while (< (point) end)
-        (setq match (re-search-forward pattern (line-end-position) t))
-        (when (or (and match (not invert))
-                  (and invert (not match)))
-          (push (move-marker (make-marker)
-                             (or (and match (match-beginning 0))
-                                 (line-beginning-position)))
-                markers))
-        (forward-line))
-      (setq markers (nreverse markers))
-      (unwind-protect
+  (evil-with-single-undo
+    (let ((case-fold-search
+           (eq (evil-ex-regex-case pattern 'smart) 'insensitive))
+          match markers)
+      (when (and pattern command)
+        (setq isearch-string pattern)
+        (isearch-update-ring pattern t)
+        (goto-char beg)
+        (evil-move-beginning-of-line)
+        (while (< (point) end)
+          (setq match (re-search-forward pattern (line-end-position) t))
+          (when (or (and match (not invert))
+                    (and invert (not match)))
+            (push (move-marker (make-marker)
+                               (or (and match (match-beginning 0))
+                                   (line-beginning-position)))
+                  markers))
+          (forward-line))
+        (setq markers (nreverse markers))
+        (unwind-protect
+            (dolist (marker markers)
+              (goto-char marker)
+              (evil-ex-eval command))
+          ;; ensure that all markers are deleted afterwards,
+          ;; even in the event of failure
           (dolist (marker markers)
-            (goto-char marker)
-            (evil-ex-eval command))
-        ;; ensure that all markers are deleted afterwards,
-        ;; even in the event of failure
-        (dolist (marker markers)
-          (set-marker marker nil))))))
+            (set-marker marker nil)))))))
 
 (evil-define-operator evil-ex-global-inverted
   (beg end pattern command &optional invert)
     (evil-test-buffer
       "[n]o 1\nno 2\nno 3\nyes 4\nno 5\nno 6\nno 7\n"
       (":g/no/s/[3-6]/x" [return])
-      "no 1\nno 2\nno x\nyes 4\nno x\nno x\n[n]o 7\n")))
+      "no 1\nno 2\nno x\nyes 4\nno x\nno x\n[n]o 7\n"
+      ("u")
+      "no 1\nno 2\nno [3]\nyes 4\nno 5\nno 6\nno 7\n")))
 
 ;;; Utilities
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.