diff --git a/rc/filetype/c-family.kak b/rc/filetype/c-family.kak index aad3ed65f..26a2b0d39 100644 --- a/rc/filetype/c-family.kak +++ b/rc/filetype/c-family.kak @@ -65,7 +65,7 @@ define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -i # Go to opening parenthesis and opening brace, then select the most nested one try %< execute-keys [c [({],[)}] > # Validate selection and get first and last char - execute-keys \A[{(](\h*\S+)+\n L + execute-keys \A[{(](\h*\S+)+\n "(([^"]*"){2})* '(([^']*'){2})* L # Remove possibly incorrect indent from new line which was copied from previous line try %< execute-keys -draft s\h+ d > # Now indent and align that new line with the opening parenthesis/brace diff --git a/test/indent/c-family/paren-in-literal/cmd b/test/indent/c-family/paren-in-literal/cmd new file mode 100644 index 000000000..8682d51ed --- /dev/null +++ b/test/indent/c-family/paren-in-literal/cmd @@ -0,0 +1 @@ +cbar diff --git a/test/indent/c-family/paren-in-literal/in b/test/indent/c-family/paren-in-literal/in new file mode 100644 index 000000000..0ca7b63c0 --- /dev/null +++ b/test/indent/c-family/paren-in-literal/in @@ -0,0 +1,7 @@ +if(c == '(') {%( ) + +if(c == '(') {}%( ) + +if(s == "(") {%( ) + +if(s == "(" "foo") {%( ) diff --git a/test/indent/c-family/paren-in-literal/out b/test/indent/c-family/paren-in-literal/out new file mode 100644 index 000000000..293dc2769 --- /dev/null +++ b/test/indent/c-family/paren-in-literal/out @@ -0,0 +1,11 @@ +if(c == '(') { + bar + +if(c == '(') {} +bar + +if(s == "(") { + bar + +if(s == "(" "foo") { + bar diff --git a/test/indent/c-family/paren-in-literal/rc b/test/indent/c-family/paren-in-literal/rc new file mode 100644 index 000000000..2c2a7247d --- /dev/null +++ b/test/indent/c-family/paren-in-literal/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/c-family.kak" +set buffer filetype cpp