@@ -8651,17 +8651,39 @@ maybe we need one line more with some text\n")
8651
8651
(ert-deftest evil-test-global ()
8652
8652
"Test `evil-ex-global'."
8653
8653
:tags '(evil ex global)
8654
+
8655
+ (defun evil-test-force-invoke-ex-hl-update-timer ()
8656
+ "Force invoke ex-hl-update-timer."
8657
+ (when evil-ex-hl-update-timer
8658
+ (timer-event-handler evil-ex-hl-update-timer)))
8659
+ (advice-add 'evil-ex-hl-idle-update :after
8660
+ #'evil-test-force-invoke-ex-hl-update-timer)
8661
+
8662
+ (defun evil-test-save-last-ex-global-hls ()
8663
+ "Save current 'evil-ex-global highlights to buffer-local variable."
8664
+ (when-let* ((hl (cdr (assq 'evil-ex-global evil-ex-active-highlights-alist)))
8665
+ (ovs (evil-ex-hl-overlays hl)))
8666
+ (setq ovs (sort ovs (lambda (a b) (< (overlay-start a) (overlay-start b)))))
8667
+ (setq-local evil-test-last-ex-global-hls
8668
+ (seq-map (lambda (ov) (buffer-substring-no-properties (overlay-start ov) (overlay-end ov)))
8669
+ ovs))))
8670
+ (advice-add 'evil-ex-hl-update-highlights :after
8671
+ #'evil-test-save-last-ex-global-hls)
8672
+
8654
8673
(ert-info ("global delete")
8655
8674
(evil-test-buffer
8656
8675
"[n]o 1\nno 2\nno 3\nyes 4\nno 5\nno 6\nno 7\n"
8657
8676
(":g/yes/d" [return])
8677
+ (should (equal evil-test-last-ex-global-hls '("yes")))
8658
8678
"no 1\nno 2\nno 3\n[n]o 5\nno 6\nno 7\n"))
8659
8679
(ert-info ("global delete, specifying case sensitivty")
8660
8680
(evil-test-buffer
8661
8681
"[a]lpha bravo charlie\nalpha Bravo charlie\nalpha BRAVO charlie\nalpha delta charlie"
8662
8682
(":g/\\CBravo/d" [return])
8683
+ (should (equal evil-test-last-ex-global-hls '("Bravo")))
8663
8684
"alpha bravo charlie\n[a]lpha BRAVO charlie\nalpha delta charlie"
8664
8685
(":g/\\cBravo/d" [return])
8686
+ (should (equal evil-test-last-ex-global-hls '("bravo" "BRAVO")))
8665
8687
"alpha delta charlie"))
8666
8688
(ert-info ("global delete with arg")
8667
8689
(evil-test-buffer
@@ -8694,6 +8716,7 @@ maybe we need one line more with some text\n")
8694
8716
("/yes" [return])
8695
8717
"no 1\nno 2\nno 3\nyes 4\nno 5\nno 6\nno 7\n"
8696
8718
(":g//d" [return])
8719
+ (should (equal evil-test-last-ex-global-hls '("yes")))
8697
8720
"no 1\nno 2\nno 3\n[n]o 5\nno 6\nno 7\n"
8698
8721
(":v//d" [return])
8699
8722
""))
@@ -8704,6 +8727,7 @@ maybe we need one line more with some text\n")
8704
8727
("/isearch" [return])
8705
8728
"no 1\nno 2\nno 3\nisearch 4\nno 5\nno 6\nno 7\n"
8706
8729
(":g//d" [return])
8730
+ (should (equal evil-test-last-ex-global-hls '("isearch")))
8707
8731
"no 1\nno 2\nno 3\n[n]o 5\nno 6\nno 7\n"
8708
8732
(":v//d" [return])
8709
8733
""))
@@ -8713,27 +8737,35 @@ maybe we need one line more with some text\n")
8713
8737
(evil-test-buffer
8714
8738
"this\nThis\n"
8715
8739
(":g/this/d" [return])
8740
+ (should (equal evil-test-last-ex-global-hls '("this")))
8716
8741
"This\n"))
8717
8742
(let ((evil-ex-search-case 'insensitive))
8718
8743
(evil-test-buffer
8719
8744
"this\nThis\n"
8720
8745
(":g/this/d" [return])
8746
+ (should (equal evil-test-last-ex-global-hls '("this" "This")))
8721
8747
""))
8722
8748
(let ((evil-ex-search-case 'smart))
8723
8749
(evil-test-buffer
8724
8750
"this\nThis\n"
8725
8751
(":g/this/d" [return])
8752
+ (should (equal evil-test-last-ex-global-hls '("this" "This")))
8726
8753
"")
8727
8754
(evil-test-buffer
8728
8755
"this\nThis\n"
8729
8756
(":g/This/d" [return])
8757
+ (should (equal evil-test-last-ex-global-hls '("This")))
8730
8758
"this\n"))))
8731
8759
(ert-info (":global should transform vim-style regexp when appropriate")
8732
8760
(let ((evil-ex-search-vim-style-regexp t))
8733
8761
(evil-test-buffer
8734
8762
"a\n1\nb\n2\nc\n3\n"
8735
8763
(":g/\\d/>")
8736
- "a\n 1\nb\n 2\nc\n 3\n"))))
8764
+ (should (equal evil-test-last-ex-global-hls '("1" "2" "3")))
8765
+ "a\n 1\nb\n 2\nc\n 3\n")))
8766
+
8767
+ (advice-remove 'evil-ex-hl-idle-update #'evil-test-force-invoke-ex-hl-update-timer)
8768
+ (advice-remove 'evil-ex-hl-update-highlights #'evil-test-save-last-ex-global-hls))
8737
8769
8738
8770
(ert-deftest evil-test-normal ()
8739
8771
"Test `evil-ex-normal'."
0 commit comments