From: Yuan Fu <casouri@gmail.com>
To: "João Paulo Labegalini de Carvalho" <jaopaulolc@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Tree-sitter modes and nested functions
Date: Thu, 1 Dec 2022 18:51:11 -0800 [thread overview]
Message-ID: <E04E69B6-CC3B-4DEE-BD16-94882293C963@gmail.com> (raw)
In-Reply-To: <CAGjvy29iOYv9M7fyvywo=TaS6ZMaQQhc-wumvQyMMmYpbRj8Sw@mail.gmail.com>
> 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
next prev parent reply other threads:[~2022-12-02 2:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-01 21:55 Tree-sitter modes and nested functions João Paulo Labegalini de Carvalho
2022-12-02 2:51 ` Yuan Fu [this message]
2022-12-03 20:00 ` João Paulo Labegalini de Carvalho
2022-12-05 20:56 ` Yuan Fu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E04E69B6-CC3B-4DEE-BD16-94882293C963@gmail.com \
--to=casouri@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=jaopaulolc@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).