diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index dc1f8824a2..f33b22852d 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1941,6 +1941,7 @@ class Reline::LineEditor @cursor = 0 end end + alias_method :kill_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) @@ -2139,9 +2140,10 @@ class Reline::LineEditor @byte_pointer -= byte_size @cursor -= width @cursor_max -= width - @kill_ring.append(deleted) + @kill_ring.append(deleted, true) end end + alias_method :unix_word_rubout, :em_kill_region private def copy_for_vi(text) if @config.editing_mode_is?(:vi_insert) or @config.editing_mode_is?(:vi_command) diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb index 2ba6a32b93..04c3254c8e 100644 --- a/test/reline/test_key_actor_emacs.rb +++ b/test/reline/test_key_actor_emacs.rb @@ -2185,6 +2185,24 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase assert_line('hoge') end + def test_em_kill_region_with_kill_ring + input_keys("def hoge\C-b\C-b\C-b\C-b", false) + assert_byte_pointer_size('def ') + assert_cursor(4) + assert_cursor_max(8) + assert_line('def hoge') + input_keys("\C-k\C-w", false) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(0) + assert_line('') + input_keys("\C-y", false) + assert_byte_pointer_size('def hoge') + assert_cursor(8) + assert_cursor_max(8) + assert_line('def hoge') + end + =begin # TODO: move KeyStroke instance from Reline to LineEditor def test_key_delete input_keys('ab')