Hi,
While working on code navigation for sh-mode with tree-sitter I think I found a bug.
When invoking `treesit-search-forward' the deepest nested function is returned instead of the first found node.
;; Contests of test.py
#!/usr/bin/env python
<---- Point position 1
def foo():
def bar(): <---- Point destination 1
return 21
return 2 * bar()
<---- Point position 2
def fuz():
def bur():
def buz(): <---- Point destination 2
return 21
return buz() + buz()
return 1 * bur()
Step to reproduce:
emacs -nw -Q ;; built from master
M-: (require 'treesit)
C-x C-f test.py
M-x python-ts-mode
;; move point to position 1
M-: (goto-char (treesit-node-start (treesit-search-forward (treesit-node-at (point)) "function_definition")))
;; point is now at destination 1
;; move point to position 2
M-: (goto-char (treesit-node-start (treesit-search-forward (treesit-node-at (point)) "function_definition")))
;; point is now at destination 2
Is this the intended behaviour?
--
João Paulo L. de Carvalho
Ph.D Computer Science | IC-UNICAMP | Campinas , SP - Brazil
Postdoctoral Research Fellow | University of Alberta | Edmonton, AB - Canada