diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-06-13 10:19:38 +0100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-06-13 10:19:38 +0100 |
| commit | e73cd78288272f7ce4e45f790f7284142c7c7e09 (patch) | |
| tree | 29be0190cd845161de33f5ab68b9afa81c487491 | |
| parent | 98627726cfd29c0b883a61ce857f950d1b26cd12 (diff) | |
Fix corner case in C family indenting
| -rw-r--r-- | rc/core/c-family.kak | 4 | ||||
| -rw-r--r-- | test/indent/c-family/align-while-expr/cmd | 1 | ||||
| -rw-r--r-- | test/indent/c-family/align-while-expr/in | 1 | ||||
| -rw-r--r-- | test/indent/c-family/align-while-expr/out | 2 | ||||
| -rw-r--r-- | test/indent/c-family/align-while-expr/rc | 3 |
5 files changed, 9 insertions, 2 deletions
diff --git a/rc/core/c-family.kak b/rc/core/c-family.kak index 2f9ab31f..3898efcb 100644 --- a/rc/core/c-family.kak +++ b/rc/core/c-family.kak @@ -49,9 +49,9 @@ def -hidden c-family-indent-on-newline %< eval -draft -itersel %< # on a previous line if its followed by text on the same line try %< eval -draft %< # Go to opening parenthesis and opening brace, then select the most nested one - try %< exec [bZ<a-\;>[B<a-z><gt> > catch %< exec [B > + try %< try %< exec [bZ<a-\;>[B<a-z><gt> > catch %< exec [B > > # Validate selection and get first and last char - exec <a-k>\`[{(](\h*\S+)+\n<ret> L s\`|.\'<ret> + exec <a-k>\`[{(](\h*\S+)+\n<ret> <a-:><a-\;>L s\`|.\'<ret> # Remove eventual indent from new line try %< exec -draft <space> <a-h> s\h+<ret> d > # Now align that new line with the opening parenthesis/brace diff --git a/test/indent/c-family/align-while-expr/cmd b/test/indent/c-family/align-while-expr/cmd new file mode 100644 index 00000000..76003030 --- /dev/null +++ b/test/indent/c-family/align-while-expr/cmd @@ -0,0 +1 @@ +c<ret><esc> diff --git a/test/indent/c-family/align-while-expr/in b/test/indent/c-family/align-while-expr/in new file mode 100644 index 00000000..85f2a9c0 --- /dev/null +++ b/test/indent/c-family/align-while-expr/in @@ -0,0 +1 @@ +while (a < b and%( )b >= c) diff --git a/test/indent/c-family/align-while-expr/out b/test/indent/c-family/align-while-expr/out new file mode 100644 index 00000000..156de3dd --- /dev/null +++ b/test/indent/c-family/align-while-expr/out @@ -0,0 +1,2 @@ +while (a < b and + b >= c) diff --git a/test/indent/c-family/align-while-expr/rc b/test/indent/c-family/align-while-expr/rc new file mode 100644 index 00000000..53c40654 --- /dev/null +++ b/test/indent/c-family/align-while-expr/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/core/c-family.kak" +set buffer filetype cpp |
