@@ -8734,17 +8734,39 @@ maybe we need one line more with some text\n")
8734
8734
(ert-deftest evil-test-global ()
8735
8735
"Test `evil-ex-global'."
8736
8736
:tags '(evil ex global)
8737
+
8738
+ (defun evil-test-force-invoke-ex-hl-update-timer ()
8739
+ "Force invoke ex-hl-update-timer."
8740
+ (when evil-ex-hl-update-timer
8741
+ (timer-event-handler evil-ex-hl-update-timer)))
8742
+ (advice-add 'evil-ex-hl-idle-update :after
8743
+ #'evil-test-force-invoke-ex-hl-update-timer)
8744
+
8745
+ (defun evil-test-save-last-ex-global-hls ()
8746
+ "Save current 'evil-ex-global highlights to buffer-local variable."
8747
+ (when-let* ((hl (cdr (assq 'evil-ex-global evil-ex-active-highlights-alist)))
8748
+ (ovs (evil-ex-hl-overlays hl)))
8749
+ (setq ovs (sort ovs (lambda (a b) (< (overlay-start a) (overlay-start b)))))
8750
+ (setq-local evil-test-last-ex-global-hls
8751
+ (seq-map (lambda (ov) (buffer-substring-no-properties (overlay-start ov) (overlay-end ov)))
8752
+ ovs))))
8753
+ (advice-add 'evil-ex-hl-update-highlights :after
8754
+ #'evil-test-save-last-ex-global-hls)
8755
+
8737
8756
(ert-info ("global delete")
8738
8757
(evil-test-buffer
8739
8758
"[n]o 1\nno 2\nno 3\nyes 4\nno 5\nno 6\nno 7\n"
8740
8759
(":g/yes/d" [return])
8760
+ (should (equal evil-test-last-ex-global-hls '("yes")))
8741
8761
"no 1\nno 2\nno 3\n[n]o 5\nno 6\nno 7\n"))
8742
8762
(ert-info ("global delete, specifying case sensitivty")
8743
8763
(evil-test-buffer
8744
8764
"[a]lpha bravo charlie\nalpha Bravo charlie\nalpha BRAVO charlie\nalpha delta charlie"
8745
8765
(":g/\\CBravo/d" [return])
8766
+ (should (equal evil-test-last-ex-global-hls '("Bravo")))
8746
8767
"alpha bravo charlie\n[a]lpha BRAVO charlie\nalpha delta charlie"
8747
8768
(":g/\\cBravo/d" [return])
8769
+ (should (equal evil-test-last-ex-global-hls '("bravo" "BRAVO")))
8748
8770
"alpha delta charlie"))
8749
8771
(ert-info ("global delete with arg")
8750
8772
(evil-test-buffer
@@ -8777,6 +8799,7 @@ maybe we need one line more with some text\n")
8777
8799
("/yes" [return])
8778
8800
"no 1\nno 2\nno 3\nyes 4\nno 5\nno 6\nno 7\n"
8779
8801
(":g//d" [return])
8802
+ (should (equal evil-test-last-ex-global-hls '("yes")))
8780
8803
"no 1\nno 2\nno 3\n[n]o 5\nno 6\nno 7\n"
8781
8804
(":v//d" [return])
8782
8805
""))
@@ -8787,6 +8810,7 @@ maybe we need one line more with some text\n")
8787
8810
("/isearch" [return])
8788
8811
"no 1\nno 2\nno 3\nisearch 4\nno 5\nno 6\nno 7\n"
8789
8812
(":g//d" [return])
8813
+ (should (equal evil-test-last-ex-global-hls '("isearch")))
8790
8814
"no 1\nno 2\nno 3\n[n]o 5\nno 6\nno 7\n"
8791
8815
(":v//d" [return])
8792
8816
""))
@@ -8796,27 +8820,35 @@ maybe we need one line more with some text\n")
8796
8820
(evil-test-buffer
8797
8821
"this\nThis\n"
8798
8822
(":g/this/d" [return])
8823
+ (should (equal evil-test-last-ex-global-hls '("this")))
8799
8824
"This\n"))
8800
8825
(let ((evil-ex-search-case 'insensitive))
8801
8826
(evil-test-buffer
8802
8827
"this\nThis\n"
8803
8828
(":g/this/d" [return])
8829
+ (should (equal evil-test-last-ex-global-hls '("this" "This")))
8804
8830
""))
8805
8831
(let ((evil-ex-search-case 'smart))
8806
8832
(evil-test-buffer
8807
8833
"this\nThis\n"
8808
8834
(":g/this/d" [return])
8835
+ (should (equal evil-test-last-ex-global-hls '("this" "This")))
8809
8836
"")
8810
8837
(evil-test-buffer
8811
8838
"this\nThis\n"
8812
8839
(":g/This/d" [return])
8840
+ (should (equal evil-test-last-ex-global-hls '("This")))
8813
8841
"this\n"))))
8814
8842
(ert-info (":global should transform vim-style regexp when appropriate")
8815
8843
(let ((evil-ex-search-vim-style-regexp t))
8816
8844
(evil-test-buffer
8817
8845
"a\n1\nb\n2\nc\n3\n"
8818
8846
(":g/\\d/>")
8819
- "a\n 1\nb\n 2\nc\n 3\n"))))
8847
+ (should (equal evil-test-last-ex-global-hls '("1" "2" "3")))
8848
+ "a\n 1\nb\n 2\nc\n 3\n")))
8849
+
8850
+ (advice-remove 'evil-ex-hl-idle-update #'evil-test-force-invoke-ex-hl-update-timer)
8851
+ (advice-remove 'evil-ex-hl-update-highlights #'evil-test-save-last-ex-global-hls))
8820
8852
8821
8853
(ert-deftest evil-test-normal ()
8822
8854
"Test `evil-ex-normal'."
0 commit comments