emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/tree-sitter 9e339415b4 14/15: Fix treesit-induce-sparse-tree


From: Yuan Fu
Subject: feature/tree-sitter 9e339415b4 14/15: Fix treesit-induce-sparse-tree
Date: Sun, 25 Sep 2022 00:12:00 -0400 (EDT)

branch: feature/tree-sitter
commit 9e339415b4c068242e7cd785d2ac95420f1934ba
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    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.
---
 src/treesit.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/treesit.c b/src/treesit.c
index 5917931e44..1a61e354cf 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]