|
From: | João Paulo Labegalini de Carvalho |
Subject: | Re: Tree-sitter modes and nested functions |
Date: | Sat, 3 Dec 2022 13:00:17 -0700 |
> On Dec 1, 2022, at 1:55 PM, João Paulo Labegalini de Carvalho <jaopaulolc@gmail.com> wrote:
>
> 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()
Yeah this is expected, treesit-search-forward searches leaf nodes first and then parent nodes. If you want to implement beginning/end-of-defun I suggest taking a look at treesit-defun-type-regexp and treesit-defun-prefer-top-level.
Yuan
[Prev in Thread] | Current Thread | [Next in Thread] |