From: Yuan Fu Date: Sun, 25 Sep 2022 03:52:32 +0000 (-0700) Subject: Fix treesit-induce-sparse-tree X-Git-Tag: emacs-29.0.90~1869 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9e339415b4c068242e7cd785d2ac95420f1934ba;p=emacs.git Fix treesit-induce-sparse-tree Because not-at-all-werid way we implemented ts_build_sparse_tree, it’s return value needs a bit post-processing (i.e., reverse its cdr). * src/treesit.c (Ftreesit_induce_sparse_tree): Reverse the top-level children list. (ts_build_sparse_tree): Add comment. --- diff --git a/src/treesit.c b/src/treesit.c index 5917931e444..1a61e354cfd 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -2041,7 +2041,9 @@ case, only 1 3 4 8 16 would be traversed. */) } /* Recursively traverse the tree under CURSOR, and append the result - subtree to PARENT's cdr. See more in `ts_build_sparse_tree'. */ + subtree to PARENT's cdr. See more in Ftreesit_induce_sparse_tree. + Note that the top-level children list is reversed, because + reasons. */ static void ts_build_sparse_tree (TSTreeCursor *cursor, Lisp_Object parent, Lisp_Object pred, @@ -2151,6 +2153,7 @@ regexp. */) ts_build_sparse_tree (&cursor, parent, predicate, process_fn, the_limit, no_limit, parser); + Fsetcdr (parent, Fnreverse (Fcdr (parent))); if (NILP (Fcdr (parent))) return Qnil; else