summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)