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:
parent
abf68320fa
commit
5696ed02e4
|
@ -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 %[
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
c<ret>}<esc>
|
8
test/indent/c-family/close-function-with-struct-param/in
Normal file
8
test/indent/c-family/close-function-with-struct-param/in
Normal file
|
@ -0,0 +1,8 @@
|
|||
void f(int i,
|
||||
struct S s)
|
||||
{
|
||||
%( )
|
||||
|
||||
void g(int i,
|
||||
struct S s) {
|
||||
%( )
|
10
test/indent/c-family/close-function-with-struct-param/out
Normal file
10
test/indent/c-family/close-function-with-struct-param/out
Normal file
|
@ -0,0 +1,10 @@
|
|||
void f(int i,
|
||||
struct S s)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void g(int i,
|
||||
struct S s) {
|
||||
|
||||
}
|
3
test/indent/c-family/close-function-with-struct-param/rc
Normal file
3
test/indent/c-family/close-function-with-struct-param/rc
Normal file
|
@ -0,0 +1,3 @@
|
|||
source "%val{runtime}/colors/default.kak"
|
||||
source "%val{runtime}/rc/filetype/c-family.kak"
|
||||
set buffer filetype cpp
|
Loading…
Reference in New Issue
Block a user