summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Tham <pickfire@riseup.net>2020-05-24 11:20:24 +0800
committerIvan Tham <pickfire@riseup.net>2020-05-30 10:54:55 +0800
commitdd3257e3f2d2a2dec759b2d2b530ff4dc5444a64 (patch)
tree3ad7c36b8ca0f655961a16a89228e34f54a83bbf
parent7c791f130c168e2b4eab699ec04983d3f7aab438 (diff)
Rust take indentation before comment to next line
-rw-r--r--rc/filetype/rust.kak2
-rw-r--r--test/indent/rust/comment/cmd1
-rw-r--r--test/indent/rust/comment/in8
-rw-r--r--test/indent/rust/comment/out11
-rw-r--r--test/indent/rust/comment/rc3
5 files changed, 24 insertions, 1 deletions
diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak
index bb998216..35788fd8 100644
--- a/rc/filetype/rust.kak
+++ b/rc/filetype/rust.kak
@@ -75,7 +75,7 @@ define-command -hidden rust-indent-on-new-line %~
evaluate-commands -draft -itersel %<
# copy // comments prefix and following white spaces
try %{
- execute-keys -draft k <a-x> s ^\h*\K//[!/]?\h* <ret> y gh j P
+ execute-keys -draft k <a-x> s ^\h*//[!/]?\h* <ret> y gh j P
} catch %`
# preserve previous line indent
try %{ execute-keys -draft <semicolon> K <a-&> }
diff --git a/test/indent/rust/comment/cmd b/test/indent/rust/comment/cmd
new file mode 100644
index 00000000..8682d51e
--- /dev/null
+++ b/test/indent/rust/comment/cmd
@@ -0,0 +1 @@
+c<ret>bar<esc>
diff --git a/test/indent/rust/comment/in b/test/indent/rust/comment/in
new file mode 100644
index 00000000..bb887d68
--- /dev/null
+++ b/test/indent/rust/comment/in
@@ -0,0 +1,8 @@
+ // foo%( )
+
+ //! foo%( )
+
+ /// foo%( )
+
+ println!("hello world"); // foo%( )
+
diff --git a/test/indent/rust/comment/out b/test/indent/rust/comment/out
new file mode 100644
index 00000000..813ec7f2
--- /dev/null
+++ b/test/indent/rust/comment/out
@@ -0,0 +1,11 @@
+ // foo
+ // bar
+
+ //! foo
+ //! bar
+
+ /// foo
+ /// bar
+
+ println!("hello world"); // foo
+ bar
diff --git a/test/indent/rust/comment/rc b/test/indent/rust/comment/rc
new file mode 100644
index 00000000..64064c25
--- /dev/null
+++ b/test/indent/rust/comment/rc
@@ -0,0 +1,3 @@
+source "%val{runtime}/colors/default.kak"
+source "%val{runtime}/rc/filetype/rust.kak"
+set buffer filetype rust