GNU bug report logs -
#65885
29.1.50; wrong behaviour of treesit-beginning-of-defun in c++-ts-mode
Previous Next
Full log
Message #11 received at 65885 <at> debbugs.gnu.org (full text, mbox):
> Date: Tue, 12 Sep 2023 12:41:32 +0800
> From: Yang Yingchao via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
> It seams that there is an issue with the behavior of `treesit-beginning-of-defun` function in
> `c++-ts-mode` when there are static variables present in the source code. For instance, in the
> provided code snippet, if the cursor is initially placed on the line containing `int b`, and the
> "C-M-a" is pressed, the cursor is positioned on line 4 instead of line 1 where the beginning of
> the function is located.
>
> ,----
> | void func // c-ts-mode: treesit-beginning-of-defun stops in this line, RIGHT
> | {
> | char * msg;
> | static int a; // c++-ts-mode: treesit-beginning-of-defun stops in this line, WRONG
> | int b; // PUT CUSOR HERE
> | }
> `----
>
> it works in c-ts-mode works normally.
If you want c++-ts-mode to work like c-ts-mode, set
treesit-defun-tactic to 'top-level'. By default, we try to support
nested defuns in C++, but not in C.
This bug report was last modified 1 year and 339 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.