GNU bug report logs -
#68664
29.1.50; treesit defun commands broken with nested functions
Previous Next
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
I've noticed that "defun" related treesit commands do not appear to work
correctly when nested functions are involved. I've seen this behavior
in multiple languages and believe the problem is an issue in the
treesit.el library.
According to the Emacs manual section "Moving by Defuns", the
beginning/end-of-defun commands should "... find the beginning and end
of the innermost defun around point". I don't see this behavior with
the corresponding treesit-beginning-of-defun and treesit-end-of-defun
commands. The following example uses python-ts-mode to demonstrate the
issue.
--8<---------------cut here---------------start------------->8---
# -*- mode: python-ts -*-
def outerFunction(text):
text = text
def innerFunction(text):
print(text)
innerFunction()
def innerFunction2(text):
print(text)
innerFunction2()
--8<---------------cut here---------------end--------------->8---
To reproduce the issue, place point on line 9 (i.e., the call to
"innerFunction"). When point is at this location, I've noticed
incorrect behavior for the following commands:
M-x treesit-beginning-of-defun RET
Moves point to the beginning of the "innerFunction" function (line 6)
instead of the beginning of the "outerFunction" function (line 3).
M-x treesit-end-of-defun RET
Moves point to the end of "innerFunction2" function (line 13) instead of
the end of the "outerFunction" function (line 15).
For comparison, the buffer can be switched to python-mode and the above
repeated with the non-treesit versions of these commands to demonstrate
that the regular python-mode does work as expected.
This bug report was last modified 1 year and 142 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.