[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/tree-sitter a73f2b9990 04/26: Fix treesit-search-forward
From: |
Yuan Fu |
Subject: |
feature/tree-sitter a73f2b9990 04/26: Fix treesit-search-forward |
Date: |
Thu, 16 Jun 2022 14:53:45 -0400 (EDT) |
branch: feature/tree-sitter
commit a73f2b9990465820d80c58ed25208b72731d410d
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Fix treesit-search-forward
Move the check for movement
(if (> arg 0)
;; Make sure we moved forward.
(> (funcall pos-fn node) starting-point)
;; Make sure we moved backward.
(< (funcall pos-fn node) starting-point))
into cl-loop:
if (treesit-node-eq cap-node node)
becomes
if (and (treesit-node-eq cap-node node)
(if (> arg 0)
;; Make sure we moved forward.
(> (funcall pos-fn node)
starting-point)
;; Make sure we moved backward.
(< (funcall pos-fn node)
starting-point)))
* lisp/treesit.el (treesit-search-forward): Move the check.
---
lisp/treesit.el | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 98fcf84355..78dfcae7e5 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -864,17 +864,20 @@ return the matched node. Return nil if search failed."
(lambda (node)
(and (not (eq (funcall pos-fn node)
starting-point))
- (if (> arg 0)
- ;; Make sure we move forward.
- (> (funcall pos-fn node) starting-point)
- ;; Make sure we move backward.
- (< (funcall pos-fn node) starting-point))
- (cl-loop for cap-node in
- (mapcar
- #'cdr
- (treesit-query-capture node query))
- if (treesit-node-eq cap-node node)
- return t)))
+ (cl-loop
+ for cap-node in
+ (mapcar
+ #'cdr
+ (treesit-query-capture node query))
+ if (and (treesit-node-eq cap-node node)
+ (if (> arg 0)
+ ;; Make sure we moved forward.
+ (> (funcall pos-fn node)
+ starting-point)
+ ;; Make sure we moved backward.
+ (< (funcall pos-fn node)
+ starting-point)))
+ return t)))
arg))
for pos = (funcall pos-fn node)
;; If we can find a match, jump to it.
- feature/tree-sitter updated (74f8572f6c -> 33f7e10a29), Yuan Fu, 2022/06/16
- feature/tree-sitter c62473c31a 05/26: Add depth control for treesit traverse functions, Yuan Fu, 2022/06/16
- feature/tree-sitter 296900184d 13/26: Add treesit-query-compile to manual, Yuan Fu, 2022/06/16
- feature/tree-sitter 57b5250474 11/26: Add test for treesit-query-compile, Yuan Fu, 2022/06/16
- feature/tree-sitter 8f3b872e30 08/26: Add new type treesit-compiled-query, Yuan Fu, 2022/06/16
- feature/tree-sitter a73f2b9990 04/26: Fix treesit-search-forward,
Yuan Fu <=
- feature/tree-sitter 35e2786c93 01/26: Fix typo and argument in treesit-beginning-of-defun, etc, Yuan Fu, 2022/06/16
- feature/tree-sitter 1dd8ddee12 02/26: Rename treesit-traverse-forward-depth-first, Yuan Fu, 2022/06/16
- feature/tree-sitter a8428b917d 09/26: * src/treesit.c (Ftreesit_query_p): New function., Yuan Fu, 2022/06/16
- feature/tree-sitter 316bdc334c 15/26: Add manual for treesit-traverse-forward and friends, Yuan Fu, 2022/06/16
- feature/tree-sitter 8aa04aac65 07/26: ; * lisp/treesit.el (treesit-defun-query): Improve docstring., Yuan Fu, 2022/06/16
- feature/tree-sitter e171ef933f 10/26: Support compiled queries in treesit-query-capture, Yuan Fu, 2022/06/16
- feature/tree-sitter b3de8850e0 06/26: Use the up-only parameter in treesit navigation functions, Yuan Fu, 2022/06/16
- feature/tree-sitter 016e4ca7a7 12/26: ; * doc/lispref/parsing.texi: Minor fix-up., Yuan Fu, 2022/06/16
- feature/tree-sitter a7288594f4 14/26: Change treesit-check-query and mention it in documentation, Yuan Fu, 2022/06/16
- feature/tree-sitter 0332b8e2c5 21/26: ; * src/treesit.c (ts_check_buffer_size): Improve error message., Yuan Fu, 2022/06/16