Skip to content

Commit 4181ae3

Browse files
committed
test: Fix hl::face-mapping test on Emacs 28
By using `tsc--hl-ensure` instead of `font-lock-ensure`.
1 parent 3cfab8a commit 4181ae3

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

tests/tree-sitter-tests-utils.el

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ If RESET is non-nil, also do another full parse and check again."
7777
"Return t if text at POS is highlighted with FACE."
7878
(memq face (tsc--listify (get-text-property pos 'face))))
7979

80+
;; In Emacs 28,`font-lock-ensure' checks `font-lock-specified-p' first.
81+
;; See https://github.com/emacs-tree-sitter/elisp-tree-sitter/pull/220#issuecomment-1120423580.
82+
(defun tsc--hl-ensure (&optional beg end)
83+
(funcall font-lock-ensure-function
84+
(or beg (point-min)) (or end (point-max))))
85+
8086
(defun tsc-test-no-op (&rest _args))
8187

8288
(defvar tsc-test-no-op

tests/tree-sitter-tests.el

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,14 +448,14 @@ source_file (1 . 20)
448448
(lambda (capture-name)
449449
(not (string= capture-name "keyword"))))
450450
(tree-sitter-hl-mode)
451-
(font-lock-ensure)
451+
(tsc--hl-ensure)
452452
(should (null (get-text-property 1 'face)))
453453
(ert-info ("Other elements should still be highlighted")
454454
(should-not (null (next-single-property-change 1 'face))))))
455455
(ert-info ("Keywords should be highlighted by default")
456456
(tsc-test-lang-with-file rust "data/types.rs"
457457
(tree-sitter-hl-mode)
458-
(font-lock-ensure)
458+
(tsc--hl-ensure)
459459
(should (tsc--hl-at 1 'tree-sitter-hl-face:keyword))))
460460
(ert-info ("Keywords should not be highlighted if their capture name is disabled")
461461
(tsc-test-lang-with-file rust "data/types.rs"
@@ -464,7 +464,7 @@ source_file (1 . 20)
464464
(lambda (capture-name)
465465
(not (string= capture-name "keyword"))))
466466
(tree-sitter-hl-mode)
467-
(font-lock-ensure)
467+
(tsc--hl-ensure)
468468
(should (null (get-text-property 1 'face)))
469469
(ert-info ("Other elements should still be highlighted")
470470
(should-not (null (next-single-property-change 1 'face))))))
@@ -473,7 +473,7 @@ source_file (1 . 20)
473473
(add-function :override (local 'tree-sitter-hl-face-mapping-function)
474474
(lambda (capture-name) nil))
475475
(tree-sitter-hl-mode)
476-
(font-lock-ensure)
476+
(tsc--hl-ensure)
477477
(ert-info ("`face' should be nil for the whole buffer")
478478
(should (null (get-text-property 1 'face)))
479479
(should (null (next-single-property-change 1 'face)))))))
@@ -483,7 +483,7 @@ source_file (1 . 20)
483483
(with-current-buffer (find-file (tsc-test-full-path "data/hl.py"))
484484
(tree-sitter-hl-mode)
485485
(font-lock-mode -1)
486-
(font-lock-ensure)
486+
(tsc--hl-ensure)
487487
(should (tsc--hl-at 6 'tree-sitter-hl-face:function))))
488488

489489
(ert-deftest debug::jump ()

0 commit comments

Comments
 (0)