summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/reline/line_editor.rb11
-rw-r--r--test/reline/test_key_actor_emacs.rb28
2 files changed, 39 insertions, 0 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index a1f12f2cfa..d94821e6fe 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -2632,6 +2632,17 @@ class Reline::LineEditor
end
alias_method :unix_line_discard, :vi_kill_line_prev
+ private def em_kill_line(key)
+ if @line.size > 0
+ @kill_ring.append(@line.dup, true)
+ @line.clear
+ @byte_pointer = 0
+ @cursor_max = 0
+ @cursor = 0
+ end
+ end
+ alias_method :kill_whole_line, :em_kill_line
+
private def em_delete(key)
if (not @is_multiline and @line.empty?) or (@is_multiline and @line.empty? and @buffer_of_lines.size == 1)
@line = nil
diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb
index a9033a85b5..a5fdf247c8 100644
--- a/test/reline/test_key_actor_emacs.rb
+++ b/test/reline/test_key_actor_emacs.rb
@@ -254,6 +254,34 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
assert_line('ab')
end
+ def test_em_kill_line
+ @line_editor.input_key(Reline::Key.new(:em_kill_line, :em_kill_line, false))
+ assert_byte_pointer_size('')
+ assert_cursor(0)
+ assert_cursor_max(0)
+ assert_line('')
+ input_keys('abc')
+ @line_editor.input_key(Reline::Key.new(:em_kill_line, :em_kill_line, false))
+ assert_byte_pointer_size('')
+ assert_cursor(0)
+ assert_cursor_max(0)
+ assert_line('')
+ input_keys('abc')
+ input_keys("\C-b", false)
+ @line_editor.input_key(Reline::Key.new(:em_kill_line, :em_kill_line, false))
+ assert_byte_pointer_size('')
+ assert_cursor(0)
+ assert_cursor_max(0)
+ assert_line('')
+ input_keys('abc')
+ input_keys("\C-a", false)
+ @line_editor.input_key(Reline::Key.new(:em_kill_line, :em_kill_line, false))
+ assert_byte_pointer_size('')
+ assert_cursor(0)
+ assert_cursor_max(0)
+ assert_line('')
+ end
+
def test_ed_move_to_beg
input_keys('abd')
assert_byte_pointer_size('abd')