Fix invalid insertion of ; after } closing some functions

Function taking a parameter with a struct tag on the last line
before the opening { were wrongly treated as structs. Add some
additional regex logic to try to catch those cases.

Fixes #4136
This commit is contained in:
Maxime Coste 2021-04-08 20:11:09 +10:00
parent abf68320fa
commit 5696ed02e4
5 changed files with 23 additions and 1 deletions

View File

@ -134,7 +134,7 @@ define-command -hidden c-family-indent-on-closing-curly-brace %[
define-command -hidden c-family-insert-on-closing-curly-brace %[
# add a semicolon after a closing brace if part of a class, union or struct definition
try %[ execute-keys -itersel -draft hm<a-x>B<a-x><a-k>\A\h*(class|struct|union|enum)<ret> '<a-;>;i;<esc>' ]
try %[ execute-keys -itersel -draft hm<a-x>B<a-x> <a-K>\A[^\n]+\)\h*(\{|$)<ret> <a-k>\A\h*(class|struct|union|enum)<ret> '<a-;>;i;<esc>' ]
]
define-command -hidden c-family-insert-on-newline %[ evaluate-commands -itersel -draft %[

View File

@ -0,0 +1 @@
c<ret>}<esc>

View File

@ -0,0 +1,8 @@
void f(int i,
struct S s)
{
%( )
void g(int i,
struct S s) {
%( )

View File

@ -0,0 +1,10 @@
void f(int i,
struct S s)
{
}
void g(int i,
struct S s) {
}

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/c-family.kak"
set buffer filetype cpp