Fix some corner cases in c-family indentation
This commit is contained in:
parent
d50048d0b4
commit
b020922e6f
|
@ -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
|
# check if alone on the line and select to opening curly brace
|
||||||
execute-keys <a-h><a-:><a-k>^\h+\}$<ret>hm
|
execute-keys <a-h><a-:><a-k>^\h+\}$<ret>hm
|
||||||
try %[
|
try %[
|
||||||
# in case open curly brace follows a closing paren, extend to opening paren
|
# in case open curly brace follows a closing paren possibly with qualifiers, extend to opening paren
|
||||||
execute-keys -draft <a-f>) <a-k> \A\)\h+\{\z <ret>
|
execute-keys -draft <a-f>) <a-k> \A\)(\h+\w+)*\h*\{\z <ret>
|
||||||
execute-keys <a-F>)M
|
execute-keys <a-F>)M
|
||||||
]
|
]
|
||||||
# align to selection start
|
# 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 %[
|
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
|
# add a semicolon after a closing brace if part of a class, union or struct definition
|
||||||
try %[ execute-keys -itersel -draft hmxBx <a-K>\A[^\n]+\)\h*(\{|$)<ret> <a-k>\A\h*(class|struct|union|enum)<ret> '<a-;>;i;<esc>' ]
|
evaluate-commands -itersel -draft -verbatim try %[
|
||||||
|
execute-keys -draft hmh <a-?>\b(class|struct|union|enum)\b<ret> <a-K>\{<ret> <a-K>\)(\s+\w+)*\s*\z<ret>
|
||||||
|
execute-keys -draft ';i;<esc>'
|
||||||
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
define-command -hidden c-family-insert-on-newline %[ evaluate-commands -itersel -draft %[
|
define-command -hidden c-family-insert-on-newline %[ evaluate-commands -itersel -draft %[
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
struct A
|
template<typename T> struct A : B
|
||||||
{
|
{
|
||||||
int i%(;)
|
struct C
|
||||||
|
{
|
||||||
|
void foo() {
|
||||||
|
bar()%(;)
|
||||||
|
}%(;)
|
||||||
|
|
||||||
|
struct D {
|
||||||
|
void baz() %({)
|
||||||
|
int qux%(;)
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
if (true) {
|
if (true) {
|
||||||
|
|
|
@ -1,6 +1,17 @@
|
||||||
struct A
|
template<typename T> struct A : B
|
||||||
{
|
{
|
||||||
int i;
|
struct C
|
||||||
|
{
|
||||||
|
void foo() {
|
||||||
|
bar();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct D {
|
||||||
|
void baz() {
|
||||||
|
}
|
||||||
|
int qux;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
|
|
|
@ -6,3 +6,13 @@ void f(int i,
|
||||||
void g(int i,
|
void g(int i,
|
||||||
struct S s) {
|
struct S s) {
|
||||||
%( )
|
%( )
|
||||||
|
|
||||||
|
struct T {
|
||||||
|
void h(int i,
|
||||||
|
struct S s) const {
|
||||||
|
%( )
|
||||||
|
|
||||||
|
void i(int i,
|
||||||
|
struct S s) const final {
|
||||||
|
%( )
|
||||||
|
};
|
||||||
|
|
|
@ -8,3 +8,15 @@ void g(int i,
|
||||||
struct S s) {
|
struct S s) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct T {
|
||||||
|
void h(int i,
|
||||||
|
struct S s) const {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void i(int i,
|
||||||
|
struct S s) const final {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user