Function: treesit--indent-largest-node-at

treesit--indent-largest-node-at is a byte-compiled function defined in treesit.el.gz.

Signature

(treesit--indent-largest-node-at POS)

Documentation

Get largest node that still starts at POS.

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit--indent-largest-node-at (pos)
  "Get largest node that still starts at POS."
  (let* ((local-parsers (treesit-local-parsers-at pos nil t))
         (smallest-node
          (cond ((car local-parsers)
                 (let ((local-parser (caar local-parsers))
                       (host-parser (cdar local-parsers)))
                   (if (eq (treesit-node-start
                            (treesit-parser-root-node local-parser))
                           pos)
                       (treesit-node-at pos host-parser)
                     (treesit-node-at pos local-parser))))
                ((null (treesit-parser-list)) nil)
                ((eq 1 (length (treesit-parser-list nil nil t)))
                 (treesit-node-at pos))
                ((treesit-language-at pos)
                 (treesit-node-at pos (treesit-language-at pos)))
                (t (treesit-node-at pos))))
         (root (treesit-parser-root-node
                (treesit-node-parser smallest-node))))
    (treesit-parent-while
     smallest-node
     (lambda (node)
       (and (eq pos (treesit-node-start node))
            (not (treesit-node-eq node root)))))))