From fcc04384d13a380dd10d3049c54d7c460aa6bf31 Mon Sep 17 00:00:00 2001 From: Dmitry Matveyev Date: Sun, 6 Jun 2021 00:38:36 +0600 Subject: [PATCH] Fix Ruby mid-comment Implementation is copied from Nim. --- rc/filetype/ruby.kak | 2 +- test/indent/ruby/insert-comment-hash/cmd | 1 + test/indent/ruby/insert-comment-hash/in | 1 + test/indent/ruby/insert-comment-hash/out | 2 ++ test/indent/ruby/insert-comment-hash/rc | 3 +++ 5 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/indent/ruby/insert-comment-hash/cmd create mode 100644 test/indent/ruby/insert-comment-hash/in create mode 100644 test/indent/ruby/insert-comment-hash/out create mode 100644 test/indent/ruby/insert-comment-hash/rc diff --git a/rc/filetype/ruby.kak b/rc/filetype/ruby.kak index 00adaa68..9c94b7be 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -173,7 +173,7 @@ define-command -hidden ruby-indent-on-new-line %{ define-command -hidden ruby-insert-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # copy _#_ comment prefix and following white spaces - try %{ execute-keys -draft k s '^\h*\K#\h*' y j P } + try %{ exec -draft k s ^\h*#\h* y jgh P } # wisely add end structure evaluate-commands -save-regs x %[ try %{ execute-keys -draft k s ^ \h + \" x y } catch %{ reg x '' } diff --git a/test/indent/ruby/insert-comment-hash/cmd b/test/indent/ruby/insert-comment-hash/cmd new file mode 100644 index 00000000..e3036a40 --- /dev/null +++ b/test/indent/ruby/insert-comment-hash/cmd @@ -0,0 +1 @@ +c diff --git a/test/indent/ruby/insert-comment-hash/in b/test/indent/ruby/insert-comment-hash/in new file mode 100644 index 00000000..450a9496 --- /dev/null +++ b/test/indent/ruby/insert-comment-hash/in @@ -0,0 +1 @@ +# Comment%( ) comment2 diff --git a/test/indent/ruby/insert-comment-hash/out b/test/indent/ruby/insert-comment-hash/out new file mode 100644 index 00000000..bde83b7a --- /dev/null +++ b/test/indent/ruby/insert-comment-hash/out @@ -0,0 +1,2 @@ +# Comment +# comment2 diff --git a/test/indent/ruby/insert-comment-hash/rc b/test/indent/ruby/insert-comment-hash/rc new file mode 100644 index 00000000..934f7e83 --- /dev/null +++ b/test/indent/ruby/insert-comment-hash/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/ruby.kak" +set buffer filetype ruby