From d8e4c6801f0fc6a76195d12f2d7690792bcd8e08 Mon Sep 17 00:00:00 2001 From: Grant Moyer Date: Wed, 27 Mar 2019 16:31:11 -0400 Subject: [PATCH] Fix autoindent issues with paren in literal --- rc/filetype/c-family.kak | 2 +- test/indent/c-family/paren-in-literal/cmd | 1 + test/indent/c-family/paren-in-literal/in | 7 +++++++ test/indent/c-family/paren-in-literal/out | 11 +++++++++++ test/indent/c-family/paren-in-literal/rc | 3 +++ 5 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/indent/c-family/paren-in-literal/cmd create mode 100644 test/indent/c-family/paren-in-literal/in create mode 100644 test/indent/c-family/paren-in-literal/out create mode 100644 test/indent/c-family/paren-in-literal/rc diff --git a/rc/filetype/c-family.kak b/rc/filetype/c-family.kak index aad3ed65..26a2b0d3 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 00000000..8682d51e --- /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 00000000..0ca7b63c --- /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 00000000..293dc276 --- /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 00000000..2c2a7247 --- /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