ruby-changes:64291
From: aycabta <ko1@a...>
Date: Sat, 19 Dec 2020 02:24:13 +0900 (JST)
Subject: [ruby-changes:64291] d4257c6152 (master): [ruby/reline] Yank by em-kill-region correctly
https://git.ruby-lang.org/ruby.git/commit/?id=d4257c6152 From d4257c6152ac9ad5179eb77d6e68942a5b9c011f Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Fri, 18 Dec 2020 23:36:33 +0900 Subject: [ruby/reline] Yank by em-kill-region correctly This closes ruby/reline#106. https://github.com/ruby/reline/commit/2549a52e15 diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index dc1f882..f33b228 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1941,6 +1941,7 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L1941 @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 https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L2140 @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 2ba6a32..04c3254 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 https://github.com/ruby/ruby/blob/trunk/test/reline/test_key_actor_emacs.rb#L2185 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') -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/