@@ -245,18 +245,22 @@ It also expects VALUE to be a single value, not a list."
245
245
(ts--point-from-position beg)
246
246
(ts--point-from-position end))
247
247
(let* ((root-node (ts-root-node tree-sitter-tree))
248
- ; ; TODO: Use `ts-query-matches' , for pattern priority.
249
- (captures (ts-query-captures
248
+ (matches (ts-query-matches
250
249
tree-sitter-hl--query
251
250
root-node
252
251
tree-sitter-hl--query-cursor
253
252
nil
254
253
#'ts--node-text )))
254
+ (sort matches (lambda (m1 m2 )
255
+ (< (car m1) (car m2))))
255
256
; ; TODO: Handle quitting.
256
- (with-silent-modifications
257
- (font-lock-unfontify-region beg end)
258
- ; ; TODO: Handle uncaptured nodes.
259
- (seq-do #'tree-sitter-hl--highlight-capture captures))
257
+ (let ((inhibit-point-motion-hooks t ))
258
+ (with-silent-modifications
259
+ (font-lock-unfontify-region beg end)
260
+ ; ; TODO: Handle uncaptured nodes.
261
+ (seq-doseq (match matches)
262
+ (pcase-let ((`(_ . , captures ) match ))
263
+ (seq-do #'tree-sitter-hl--highlight-capture captures)))))
260
264
; ; TODO: Return the actual region being fontified.
261
265
`(jit-lock-bounds , beg . , end ))))
262
266
0 commit comments