@@ -8865,17 +8865,39 @@ maybe we need one line more with some text\n")
8865
8865
(ert-deftest evil-test-global ()
8866
8866
"Test `evil-ex-global'."
8867
8867
:tags '(evil ex global)
8868
+
8869
+ (defun evil-test-force-invoke-ex-hl-update-timer ()
8870
+ "Force invoke ex-hl-update-timer."
8871
+ (when evil-ex-hl-update-timer
8872
+ (timer-event-handler evil-ex-hl-update-timer)))
8873
+ (advice-add 'evil-ex-hl-idle-update :after
8874
+ #'evil-test-force-invoke-ex-hl-update-timer)
8875
+
8876
+ (defun evil-test-save-last-ex-global-hls ()
8877
+ "Save current 'evil-ex-global highlights to buffer-local variable."
8878
+ (when-let* ((hl (cdr (assq 'evil-ex-global evil-ex-active-highlights-alist)))
8879
+ (ovs (evil-ex-hl-overlays hl)))
8880
+ (setq ovs (sort ovs (lambda (a b) (< (overlay-start a) (overlay-start b)))))
8881
+ (setq-local evil-test-last-ex-global-hls
8882
+ (seq-map (lambda (ov) (buffer-substring-no-properties (overlay-start ov) (overlay-end ov)))
8883
+ ovs))))
8884
+ (advice-add 'evil-ex-hl-update-highlights :after
8885
+ #'evil-test-save-last-ex-global-hls)
8886
+
8868
8887
(ert-info ("global delete")
8869
8888
(evil-test-buffer
8870
8889
"[n]o 1\nno 2\nno 3\nyes 4\nno 5\nno 6\nno 7\n"
8871
8890
(":g/yes/d" [return])
8891
+ (should (equal evil-test-last-ex-global-hls '("yes")))
8872
8892
"no 1\nno 2\nno 3\n[n]o 5\nno 6\nno 7\n"))
8873
8893
(ert-info ("global delete, specifying case sensitivty")
8874
8894
(evil-test-buffer
8875
8895
"[a]lpha bravo charlie\nalpha Bravo charlie\nalpha BRAVO charlie\nalpha delta charlie"
8876
8896
(":g/\\CBravo/d" [return])
8897
+ (should (equal evil-test-last-ex-global-hls '("Bravo")))
8877
8898
"alpha bravo charlie\n[a]lpha BRAVO charlie\nalpha delta charlie"
8878
8899
(":g/\\cBravo/d" [return])
8900
+ (should (equal evil-test-last-ex-global-hls '("bravo" "BRAVO")))
8879
8901
"alpha delta charlie"))
8880
8902
(ert-info ("global delete with arg")
8881
8903
(evil-test-buffer
@@ -8908,6 +8930,7 @@ maybe we need one line more with some text\n")
8908
8930
("/yes" [return])
8909
8931
"no 1\nno 2\nno 3\nyes 4\nno 5\nno 6\nno 7\n"
8910
8932
(":g//d" [return])
8933
+ (should (equal evil-test-last-ex-global-hls '("yes")))
8911
8934
"no 1\nno 2\nno 3\n[n]o 5\nno 6\nno 7\n"
8912
8935
(":v//d" [return])
8913
8936
""))
@@ -8918,6 +8941,7 @@ maybe we need one line more with some text\n")
8918
8941
("/isearch" [return])
8919
8942
"no 1\nno 2\nno 3\nisearch 4\nno 5\nno 6\nno 7\n"
8920
8943
(":g//d" [return])
8944
+ (should (equal evil-test-last-ex-global-hls '("isearch")))
8921
8945
"no 1\nno 2\nno 3\n[n]o 5\nno 6\nno 7\n"
8922
8946
(":v//d" [return])
8923
8947
""))
@@ -8927,27 +8951,35 @@ maybe we need one line more with some text\n")
8927
8951
(evil-test-buffer
8928
8952
"this\nThis\n"
8929
8953
(":g/this/d" [return])
8954
+ (should (equal evil-test-last-ex-global-hls '("this")))
8930
8955
"This\n"))
8931
8956
(let ((evil-ex-search-case 'insensitive))
8932
8957
(evil-test-buffer
8933
8958
"this\nThis\n"
8934
8959
(":g/this/d" [return])
8960
+ (should (equal evil-test-last-ex-global-hls '("this" "This")))
8935
8961
""))
8936
8962
(let ((evil-ex-search-case 'smart))
8937
8963
(evil-test-buffer
8938
8964
"this\nThis\n"
8939
8965
(":g/this/d" [return])
8966
+ (should (equal evil-test-last-ex-global-hls '("this" "This")))
8940
8967
"")
8941
8968
(evil-test-buffer
8942
8969
"this\nThis\n"
8943
8970
(":g/This/d" [return])
8971
+ (should (equal evil-test-last-ex-global-hls '("This")))
8944
8972
"this\n"))))
8945
8973
(ert-info (":global should transform vim-style regexp when appropriate")
8946
8974
(let ((evil-ex-search-vim-style-regexp t))
8947
8975
(evil-test-buffer
8948
8976
"a\n1\nb\n2\nc\n3\n"
8949
8977
(":g/\\d/>")
8950
- "a\n 1\nb\n 2\nc\n 3\n"))))
8978
+ (should (equal evil-test-last-ex-global-hls '("1" "2" "3")))
8979
+ "a\n 1\nb\n 2\nc\n 3\n")))
8980
+
8981
+ (advice-remove 'evil-ex-hl-idle-update #'evil-test-force-invoke-ex-hl-update-timer)
8982
+ (advice-remove 'evil-ex-hl-update-highlights #'evil-test-save-last-ex-global-hls))
8951
8983
8952
8984
(ert-deftest evil-test-normal ()
8953
8985
"Test `evil-ex-normal'."
0 commit comments