Subject: bug#66159: [PATCH] Various improvements to lua-ts-mode (Bug#66159)

From: Andrey Listopadov <[email-masked]>
Date: Sun, 08 Oct 2023 12:43:50 +0300

john muhl <[email-masked]> writes:

>> It seems the last patch broke the movement.
>
> The tests for those pass and are still working here. Maybe you found
> another case that needs to be improved. What is the specific problem?

It seems so, sorry for not including this, I thought I sent this before.
Here's an example:

█for i=1,10 do
     print(x)
 end

Pressing Pressing C-M-f (forward-sexp) puts the point here:

 for i=1,10 do
     print(x)█
 end

I think it should go over the `for' loop right to the `end'.

Pressing Pressing C-M-b (backward-sexp), however, puts the point here:

 for i=1,10 do
    █print(x)
 end

Pressing C-M-b again doesn't move the point anymore.

Same thing happens with for-each style loop:

█for k,v in pairs({1,2,3}) do
     print(x)
 end

C-M-f:

 for k,v in pairs({1,2,3})█do
     print(x)
 end

C-M-f:

 for k,v in pairs({1,2,3}) do
     print(x)█
 end

Backward movement manages to take the point way back to the pairs:

C-M-b, C-M-b:

 for k,v in pairs█({1,2,3}) do
     print(x)
 end

I went to https://devhints.io/lua and copied a bunch of examples of
other loops to the scratch buffer, and the movement is as follows:

█while condition do
 end

 for i = 1,5 do
 end

 for i = start,finish,delta do
 end

 for k,v in pairs(tab) do
 end

 repeat
 until condition

 -- Breaking out:
 while x do
   if condition then break end
 end

C-M-f:

 while condition do
 end

 for i = 1,5 do
 end

 for i = start,finish,delta do
 end

 for k,v in pairs(tab)█do
 end

 repeat
 until condition

 -- Breaking out:
 while x do
   if condition then break end
 end

C-M-f:

 while condition do
 end

 for i = 1,5 do
 end

 for i = start,finish,delta do
 end

 for k,v in pairs(tab) do
 end

 repeat
 until condition

 -- Breaking out:
 while x do
   if condition then break end█
 end

--
Andrey Listopadov