1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-23 07:15:52 +03:00

lua.kak: Add some test cases, and also fix a bug

This commit is contained in:
Hugo Musso Gualandi 2021-09-26 11:19:58 -03:00
parent aa1a280309
commit c26fb65ed1
3 changed files with 31 additions and 3 deletions

View File

@ -136,7 +136,7 @@ define-command -hidden lua-insert-on-new-line %[
<a-k>^\h*\b(else|elseif|do|for|function|if|while)\b|[^\n]\bfunction\b\h*[(]<ret> \
<a-K>\bend\b<ret>
# check that the block is empty and is not closed on a different line
execute-keys -draft <a-a>i <a-K>^[^\n]*\n[^\n]*\n<ret> j<a-x> <a-K>^<c-r>x\b(else|elseif|end)\b<ret>
execute-keys -draft <a-a>i <a-K>^[^\n]+\n[^\n]+\n<ret> j<a-x> <a-K>^<c-r>x\b(else|elseif|end)\b<ret>
# auto insert end
execute-keys -draft o<c-r>xend<esc>
# auto insert ) for anonymous function

View File

@ -3,7 +3,19 @@ end
function fun2()%( )
function fun3()
if true then%( )
end
function fun4()
if true then
return 10
else%( )
end
function fun5()
if true then%( )
return 10
end
local str = "while"%( )

View File

@ -6,9 +6,25 @@ function fun2()
foo()
end
function fun3()
if true then
foo()
end
end
function fun4()
if true then
return 10
else
foo()
end
end
function fun5()
if true then
foo()
return 10
end
local str = "while"
foo()