From d8f00198f375c90a8f1682bb880ec915f5c6b0e2 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 9 Dec 2016 13:50:41 +0000 Subject: [PATCH] Improve C indentation support around namespace/struct closing bracket --- rc/core/c-family.kak | 4 ++-- test/indent/c-family/close-namespace/cmd | 1 + test/indent/c-family/close-namespace/in | 3 +++ test/indent/c-family/close-namespace/out | 4 ++++ test/indent/c-family/close-namespace/rc | 3 +++ test/indent/c-family/close-struct/cmd | 1 + test/indent/c-family/close-struct/in | 3 +++ test/indent/c-family/close-struct/out | 4 ++++ test/indent/c-family/close-struct/rc | 3 +++ 9 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 test/indent/c-family/close-namespace/cmd create mode 100644 test/indent/c-family/close-namespace/in create mode 100644 test/indent/c-family/close-namespace/out create mode 100644 test/indent/c-family/close-namespace/rc create mode 100644 test/indent/c-family/close-struct/cmd create mode 100644 test/indent/c-family/close-struct/in create mode 100644 test/indent/c-family/close-struct/out create mode 100644 test/indent/c-family/close-struct/rc diff --git a/rc/core/c-family.kak b/rc/core/c-family.kak index 63d1ee19..44febf36 100644 --- a/rc/core/c-family.kak +++ b/rc/core/c-family.kak @@ -68,12 +68,12 @@ def -hidden _c-family-indent-on-opening-curly-brace %[ def -hidden _c-family-indent-on-closing-curly-brace %[ # align to opening curly brace when alone on a line - try %[ exec -itersel -draft ^\h+\}$hms\`|.\'1 ] + try %[ exec -itersel -draft ^\h+\}$hms\`|.\'1 ] ] def -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 %[ exec -itersel -draft hmB^\h*(class|struct|union) a\; ] + try %[ exec -itersel -draft hmB\`\h*(class|struct|union) a\; ] ] def -hidden _c-family-insert-on-newline %[ eval -draft %[ diff --git a/test/indent/c-family/close-namespace/cmd b/test/indent/c-family/close-namespace/cmd new file mode 100644 index 00000000..f856dbeb --- /dev/null +++ b/test/indent/c-family/close-namespace/cmd @@ -0,0 +1 @@ +a} diff --git a/test/indent/c-family/close-namespace/in b/test/indent/c-family/close-namespace/in new file mode 100644 index 00000000..772f74c0 --- /dev/null +++ b/test/indent/c-family/close-namespace/in @@ -0,0 +1,3 @@ +namespace A +{ + struct B%(;) diff --git a/test/indent/c-family/close-namespace/out b/test/indent/c-family/close-namespace/out new file mode 100644 index 00000000..e9fab7f9 --- /dev/null +++ b/test/indent/c-family/close-namespace/out @@ -0,0 +1,4 @@ +namespace A +{ + struct B; +} diff --git a/test/indent/c-family/close-namespace/rc b/test/indent/c-family/close-namespace/rc new file mode 100644 index 00000000..53c40654 --- /dev/null +++ b/test/indent/c-family/close-namespace/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/core/c-family.kak" +set buffer filetype cpp diff --git a/test/indent/c-family/close-struct/cmd b/test/indent/c-family/close-struct/cmd new file mode 100644 index 00000000..f856dbeb --- /dev/null +++ b/test/indent/c-family/close-struct/cmd @@ -0,0 +1 @@ +a} diff --git a/test/indent/c-family/close-struct/in b/test/indent/c-family/close-struct/in new file mode 100644 index 00000000..149f2a22 --- /dev/null +++ b/test/indent/c-family/close-struct/in @@ -0,0 +1,3 @@ +struct A +{ + int i%(;) diff --git a/test/indent/c-family/close-struct/out b/test/indent/c-family/close-struct/out new file mode 100644 index 00000000..67c4f51a --- /dev/null +++ b/test/indent/c-family/close-struct/out @@ -0,0 +1,4 @@ +struct A +{ + int i; +}; diff --git a/test/indent/c-family/close-struct/rc b/test/indent/c-family/close-struct/rc new file mode 100644 index 00000000..53c40654 --- /dev/null +++ b/test/indent/c-family/close-struct/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/core/c-family.kak" +set buffer filetype cpp