summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtávio Schwanck dos Santos <otavioschwanck@gmail.com>2024-02-11 10:03:47 +0000
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2024-02-13 18:57:17 +0900
commite848848b58adbf7b5d60537a89cc8de4c48de15e (patch)
tree88a0c45659557f0d92ec25424b1a3ccd72801210
parent01d4d5b8b37609bfee5f23d288534d6e465129cc (diff)
[ruby/reline] C for vi mode
(https://github.com/ruby/reline/pull/472) https://github.com/ruby/reline/commit/d197be7c44
-rw-r--r--lib/reline/line_editor.rb7
-rw-r--r--test/reline/test_key_actor_vi.rb10
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 57306673cd..b7cc6b747d 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -2563,6 +2563,13 @@ class Reline::LineEditor
end
alias_method :kill_line, :ed_kill_line
+ # Editline:: +vi_change_to_eol+ (vi command: +C+) + Kill and change from the cursor to the end of the line.
+ private def vi_change_to_eol(key)
+ ed_kill_line(key)
+
+ @config.editing_mode = :vi_insert
+ end
+
# Editline:: +vi-kill-line-prev+ (vi: +Ctrl-U+) Delete the string from the
# beginning of the edit buffer to the cursor and save it to the
# cut buffer.
diff --git a/test/reline/test_key_actor_vi.rb b/test/reline/test_key_actor_vi.rb
index 20630e5809..7c924d1963 100644
--- a/test/reline/test_key_actor_vi.rb
+++ b/test/reline/test_key_actor_vi.rb
@@ -1455,6 +1455,16 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase
assert_line('c')
end
+ def test_vi_change_to_eol
+ input_keys("abcdef\C-[2hC")
+ assert_line("abc")
+ input_keys("\C-[0C")
+ assert_line("")
+ assert_cursor(0)
+ assert_cursor_max(0)
+ assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
+ end
+
def test_vi_motion_operators
assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)