Function: treesit-fold-range-markers

treesit-fold-range-markers is a natively compiled function defined in treesit-fold.el.

Signature

(treesit-fold-range-markers NODE OFFSET START-SEQ &optional END-SEQ)

Documentation

Return the fold range for NODE with an OFFSET where the range starts at the end of the first occurence of START-SEQ and ends at the end of the node or the start of the last occurence of the optional parameter LAST-SEQ.

START-SEQ and LAST-SEQ can be named tree-sitter nodes or anonomous nodes.

If no occurence is found for START-SEQ or END-SEQ or the occurences overlap, then the range returned is nil.

Source Code

;; Defined in /nix/store/mpy1l6b4hlzpp59l4vbahq83hqa821ci-emacs-packages-deps/share/emacs/site-lisp/elpa/treesit-fold-0.2.1/treesit-fold.el
(defun treesit-fold-range-markers (node offset start-seq &optional end-seq)
  "Return the fold range for NODE with an OFFSET where the range starts at
the end of the first occurence of START-SEQ and ends at the end of the node
or the start of the last occurence of the optional parameter LAST-SEQ.

START-SEQ and LAST-SEQ can be named tree-sitter nodes or anonomous nodes.

If no occurence is found for START-SEQ or END-SEQ or the
occurences overlap, then the range returned is nil."
  (when start-seq
    (when-let* ((beg-node (car (treesit-fold-find-children node start-seq)))
                (end-node (if end-seq
                              (car (last (treesit-fold-find-children node end-seq)))
                            node))
                (beg (treesit-node-end beg-node))
                (end (if end-seq
                         (treesit-node-start end-node)
                       (1- (treesit-node-end node)))))
      (unless (> beg end) (treesit-fold--cons-add (cons beg end) offset)))))