From 785cbaeaed59d4ec78ad2935b5ef2ac340e2ac03 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sun, 27 Sep 2020 23:34:08 +0800 Subject: [PATCH] Add rust test for empty line indent --- rc/filetype/rust.kak | 2 +- test/indent/rust/empty-line/cmd | 1 + test/indent/rust/empty-line/in | 2 ++ test/indent/rust/empty-line/out | 3 +++ test/indent/rust/empty-line/rc | 3 +++ 5 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/indent/rust/empty-line/cmd create mode 100644 test/indent/rust/empty-line/in create mode 100644 test/indent/rust/empty-line/out create mode 100644 test/indent/rust/empty-line/rc diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index f2fbfee1..51b5ef67 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -151,7 +151,7 @@ define-command -hidden rust-indent-on-new-line %~ # indent after lines ending with [{(].+ and move first parameter to own line try %< execute-keys -draft [c[({],[)}] \A[({][^\n]+\n[^\n]*\n?\z L i > # indent after non-empty lines not starting with operator and not ending with , or ; - # XXX s [^\h]* is workaround for broken negate match #3766, use this later + # XXX simplify this into a single without s try %< execute-keys -draft k s [^\h].+ \A[-+*/&|^})] [,](\h*/[/*].*|)$ j > # dedent after lines starting with . and ending with } or ) or , or ; try %_ execute-keys -draft k ^\h*\..*[}),]\h*$ j _ diff --git a/test/indent/rust/empty-line/cmd b/test/indent/rust/empty-line/cmd new file mode 100644 index 00000000..8682d51e --- /dev/null +++ b/test/indent/rust/empty-line/cmd @@ -0,0 +1 @@ +cbar diff --git a/test/indent/rust/empty-line/in b/test/indent/rust/empty-line/in new file mode 100644 index 00000000..e4ed2188 --- /dev/null +++ b/test/indent/rust/empty-line/in @@ -0,0 +1,2 @@ + %( ) + diff --git a/test/indent/rust/empty-line/out b/test/indent/rust/empty-line/out new file mode 100644 index 00000000..4567eae7 --- /dev/null +++ b/test/indent/rust/empty-line/out @@ -0,0 +1,3 @@ + + bar + diff --git a/test/indent/rust/empty-line/rc b/test/indent/rust/empty-line/rc new file mode 100644 index 00000000..64064c25 --- /dev/null +++ b/test/indent/rust/empty-line/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/rust.kak" +set buffer filetype rust