Subject: bug#62302: 30.0.50; c/c++ tree sitter forward-sexp problem

From: Yuan Fu <[email-masked]>
Date: Thu, 6 Apr 2023 14:55:11 -0700

Eli Zaretskii <[email-masked]> writes:

>> Date: Mon, 20 Mar 2023 21:40:26 +0100
>> From: "Herman, Geza" <[email-masked]>
>> 
>> With tree sitter, forward-sexp behaves a little strange. To reproduce:
>>   - copy the little example program below into a c++-ts-mode buffer
>>   - move the point to the opening curly brace of "main() {"
>>   - M-x forward-sexp
>> 
>> This will move the point to the space character in "int a;". But without 
>> tree sitter, this moves the point to the closing brace of main (I 
>> believe this is the correct behavior).
>> 
>> I noticed this problem because hideshow behaves strangely with tree sitter:
>>   - enable hideshow mode (M-x hs-minor-mode)
>>   - move the point to the same opening brace
>>   - M-x hs-toggle-hiding
>> 
>> Hideshow should hide the whole body of main, but instead it only hides 
>> parts of the body, and the buffer ends up like this:
>> 
>> int main() {... a;
>>      }
>>     int b;
>> }
>> 
>> If I set forward-sexp-function to nil, the problem goes away. I think 
>> this issue is somewhat related to #60894
>> 
>> Here's the little example program:
>> 
>> int main() {
>>      if (false) {
>>          int a;
>>      }
>>      int b;
>> }
>
> Theo, Yuan: any comments?  Can you look into fixing this?
>
> Thanks.

Missed this, sorry :-)

I modified the definition of "sexp" in c/c++-ts-mode. I think new
definition is intuitive but only time will tell. The new definition
works on the little example in this report.

Yuan