diff --git a/rc/filetype/c-family.kak b/rc/filetype/c-family.kak index e7c440ba..b968c807 100644 --- a/rc/filetype/c-family.kak +++ b/rc/filetype/c-family.kak @@ -126,8 +126,8 @@ define-command -hidden c-family-indent-on-closing-curly-brace %[ # check if alone on the line and select to opening curly brace execute-keys ^\h+\}$hm try %[ - # in case open curly brace follows a closing paren, extend to opening paren - execute-keys -draft ) \A\)\h+\{\z + # in case open curly brace follows a closing paren possibly with qualifiers, extend to opening paren + execute-keys -draft ) \A\)(\h+\w+)*\h*\{\z execute-keys )M ] # align to selection start @@ -137,7 +137,10 @@ 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 hmxBx \A[^\n]+\)\h*(\{|$) \A\h*(class|struct|union|enum) ';i;' ] + evaluate-commands -itersel -draft -verbatim try %[ + execute-keys -draft hmh \b(class|struct|union|enum)\b \{ \)(\s+\w+)*\s*\z + execute-keys -draft ';i;' + ] ] define-command -hidden c-family-insert-on-newline %[ evaluate-commands -itersel -draft %[ diff --git a/test/indent/c-family/close-block/in b/test/indent/c-family/close-block/in index bc0901e8..7e52c42f 100644 --- a/test/indent/c-family/close-block/in +++ b/test/indent/c-family/close-block/in @@ -1,6 +1,14 @@ -struct A +template struct A : B { - int i%(;) + struct C + { + void foo() { + bar()%(;) + }%(;) + +struct D { + void baz() %({) + int qux%(;) if (true) { if (true) { diff --git a/test/indent/c-family/close-block/out b/test/indent/c-family/close-block/out index b207dfd6..2f20296b 100644 --- a/test/indent/c-family/close-block/out +++ b/test/indent/c-family/close-block/out @@ -1,6 +1,17 @@ -struct A +template struct A : B { - int i; + struct C + { + void foo() { + bar(); + } + }; +}; + +struct D { + void baz() { + } + int qux; }; if (true) { diff --git a/test/indent/c-family/close-function-with-struct-param/in b/test/indent/c-family/close-function-with-struct-param/in index c0a2e31c..97ff4736 100644 --- a/test/indent/c-family/close-function-with-struct-param/in +++ b/test/indent/c-family/close-function-with-struct-param/in @@ -6,3 +6,13 @@ void f(int i, void g(int i, struct S s) { %( ) + +struct T { + void h(int i, + struct S s) const { + %( ) + + void i(int i, + struct S s) const final { + %( ) +}; diff --git a/test/indent/c-family/close-function-with-struct-param/out b/test/indent/c-family/close-function-with-struct-param/out index 053db0aa..d7ba56c7 100644 --- a/test/indent/c-family/close-function-with-struct-param/out +++ b/test/indent/c-family/close-function-with-struct-param/out @@ -8,3 +8,15 @@ void g(int i, struct S s) { } + +struct T { + void h(int i, + struct S s) const { + + } + + void i(int i, + struct S s) const final { + + } +};