]> git.eshelyaron.com Git - emacs.git/commitdiff
(treesit-simple-indent-presets): Have n-p-gp check for grandparent's presence
authorDmitry Gutov <dgutov@yandex.ru>
Thu, 19 Jan 2023 17:43:19 +0000 (19:43 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Thu, 19 Jan 2023 17:44:10 +0000 (19:44 +0200)
* lisp/treesit.el (treesit-simple-indent-presets): Have n-p-gp
check for grandparent's presence before checking its type.

lisp/treesit.el

index 34d288226fafcd926d76e860ca0baeb92058bf16..7669ed6d18c096be9662b22c346f715e532dafcb 100644 (file)
@@ -1102,10 +1102,12 @@ See `treesit-simple-indent-presets'.")
                            (string-match-p
                             parent-t (treesit-node-type parent)))
                        (or (null grand-parent-t)
-                           (string-match-p
-                            grand-parent-t
-                            (treesit-node-type
-                             (treesit-node-parent parent))))))))
+                           (and
+                            (treesit-node-parent parent)
+                            (string-match-p
+                             grand-parent-t
+                             (treesit-node-type
+                              (treesit-node-parent parent)))))))))
         (cons 'no-node (lambda (node &rest _) (null node)))
         (cons 'parent-is (lambda (type)
                            (lambda (_n parent &rest _)