(defun c-ts-mode--outline-predicate (node)
"Match outlines on lines with function names."
- (or (when-let* ((decl (treesit-node-child-by-field-name
- (treesit-node-parent node) "declarator"))
- (node-pos (treesit-node-start node))
- (decl-pos (treesit-node-start decl))
- (eol (save-excursion (goto-char node-pos) (line-end-position))))
- (and (equal (treesit-node-type decl) "function_declarator")
- (<= node-pos decl-pos)
- (< decl-pos eol)))
+ (or (and (equal (treesit-node-type node) "function_declarator")
+ ;; Handle the case when "function_definition" is
+ ;; not an immediate parent of "function_declarator"
+ ;; but there is e.g. "pointer_declarator" between them.
+ (treesit-parent-until node "function_definition"))
;; DEFUNs in Emacs sources.
(and c-ts-mode-emacs-sources-support
(c-ts-mode--emacs-defun-p node))))
(defun yaml-ts-mode--outline-predicate (node)
"Limit outlines to top-level mappings."
- (when (equal (treesit-node-type node) "block_mapping_pair")
- (not (treesit-parent-until node treesit-outline-predicate))))
+ (let ((regexp (rx (or "block_mapping_pair" "block_sequence_item"))))
+ (when (string-match-p regexp (treesit-node-type node))
+ (not (treesit-parent-until node regexp)))))
;;;###autoload
(define-derived-mode yaml-ts-mode text-mode "YAML"