bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#68652: 29.1.50; treesit defun commands broken near beginning of func


From: Troy Brown
Subject: bug#68652: 29.1.50; treesit defun commands broken near beginning of function
Date: Sun, 21 Jan 2024 23:47:08 -0500

I've noticed that "defun" related treesit commands/functions do not
appear to work correctly near the beginning of a function.  I've seen
this behavior in multiple languages and believe the problem is an issue
in the treesit.el library.  Also, I believe the issue occurs on the
first token of the function definition.  The following example uses
c-ts-mode to demonstrate the issue.

--8<---------------cut here---------------start------------->8---
// -*- mode: c-ts -*-

void previous (void);
void next (void);

void previous (void) {
}

void main (void) {
  previous();
  next();
  printf("Hello, world!\n");
}

void next (void) {
}
--8<---------------cut here---------------end--------------->8---

To reproduce the issue, place point between the "o" and "i" of the
"void" return type for the "main" function.  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 previous function instead of the
beginning of the current (i.e., "main") function.

M-x treesit-end-of-defun RET

This does not move point, when it should move to the end of the current
function.

I've also noticed functions, such as "treesit-defun-at-point" behave
incorrectly here as well (i.e., returns "nil" instead of the function
definition node).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]