Function: treesit--explorer-highlight-node

treesit--explorer-highlight-node is a byte-compiled function defined in treesit.el.gz.

Signature

(treesit--explorer-highlight-node NODES)

Documentation

Highlight nodes in NODES in the syntax tree buffer.

Return the start of the syntax tree text corresponding to NODE.

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit--explorer-highlight-node (nodes)
  "Highlight nodes in NODES in the syntax tree buffer.
Return the start of the syntax tree text corresponding to NODE."
  (when treesit--explorer-highlight-overlay
    (delete-overlay treesit--explorer-highlight-overlay))
  (let ((start-node (car nodes))
        (end-node (car (last nodes)))
        start end)
    (when (and start-node end-node)
      (cl-loop for ov in (overlays-in (point-min) (point-max))
               while (or (null start) (null end))
               if (treesit-node-eq start-node
                                   (overlay-get ov 'treesit-node))
               do (setq start (overlay-start ov))
               if (treesit-node-eq end-node (overlay-get ov 'treesit-node))
               do (setq end (overlay-end ov)))
      ;; FIXME: Fix highlighting for a node that spans across multiple
      ;; ranges: the buffer region in-between ranges shouldn't be
      ;; highlighted.
      (when (and start end)
        (setq-local treesit--explorer-highlight-overlay
                    (make-overlay start end))
        (overlay-put treesit--explorer-highlight-overlay
                     'face 'highlight)
        start))))