bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#67117: [PATCH] Tree-sitter: fix an issue when searching subtree back


From: Denis Zubarev
Subject: bug#67117: [PATCH] Tree-sitter: fix an issue when searching subtree backward
Date: Sun, 12 Nov 2023 02:38:33 +0300

Tags: patch


Steps to reproduce the issue:
1. emacs -Q
2. M-x find-file /tmp/t.py
3. paste to the buffer
 
Temp(1, 2) 
 
4. M-x python-ts-mode
5. Call search-subtree with backward flag
   M-x eval-expression (treesit-search-subtree
               (treesit--thing-at (point) "call")
               (lambda (n) (equal (treesit-node-type n ) "integer"))
               t)
It should return the second int node (#<treesit-node integer in 9-10>), but it 
returns nil.

I fixed it in treesit_traverse_child_helper.
Do not call treesit_traverse_sibling_helper when the named node is
required and the last child is the named node.
Otherwise treesit_traverse_sibling_helper will move cursor to the
previous sibling and the last node will be skipped.
I've added test for this bug.




In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.33, cairo version 1.16.0) of 2023-11-12 built on NUC-here
Repository revision: 400a71b8f2c5a49dce4f542adfd2fdb59eb34243
Repository branch: search-subtree-bacward-fix
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Ubuntu 22.04.3 LTS

Configured using:
 'configure --with-modules --with-native-compilation=aot
 --with-imagemagick --with-json --with-tree-sitter --with-xft'

Attachment: 0001-Fix-an-issue-when-searching-subtree-backward.patch
Description: Text Data


reply via email to

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