ruby-changes:64290
From: aycabta <ko1@a...>
Date: Sat, 19 Dec 2020 02:24:09 +0900 (JST)
Subject: [ruby-changes:64290] af2c81e10c (master): [ruby/reline] Bind yank-pop correctly
https://git.ruby-lang.org/ruby.git/commit/?id=af2c81e10c From af2c81e10c15c267611e59f11b7152545c617826 Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Fri, 18 Dec 2020 23:35:15 +0900 Subject: [ruby/reline] Bind yank-pop correctly https://github.com/ruby/reline/commit/3c74beac65 diff --git a/lib/reline/key_actor/emacs.rb b/lib/reline/key_actor/emacs.rb index 1e51d4f..cad97a7 100644 --- a/lib/reline/key_actor/emacs.rb +++ b/lib/reline/key_actor/emacs.rb @@ -307,7 +307,7 @@ class Reline::KeyActor::Emacs < Reline::KeyActor::Base https://github.com/ruby/ruby/blob/trunk/lib/reline/key_actor/emacs.rb#L307 # 152 M-^X :ed_unassigned, # 153 M-^Y - :ed_unassigned, + :em_yank_pop, # 154 M-^Z :ed_unassigned, # 155 M-^[ diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index b80a184..dc1f882 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1991,6 +1991,7 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L1991 @byte_pointer += yanked.bytesize end end + alias_method :yank, :em_yank private def em_yank_pop(key) yanked, prev_yank = @kill_ring.yank_pop @@ -2007,6 +2008,7 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L2008 @byte_pointer += yanked.bytesize end end + alias_method :yank_pop, :em_yank_pop private def ed_clear_screen(key) @cleared = true diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb index 5ec8be6..2ba6a32 100644 --- a/test/reline/test_key_actor_emacs.rb +++ b/test/reline/test_key_actor_emacs.rb @@ -2167,6 +2167,24 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase https://github.com/ruby/ruby/blob/trunk/test/reline/test_key_actor_emacs.rb#L2167 end end + def test_em_yank_pop + input_keys("def hoge\C-w\C-b\C-f\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 ') + assert_cursor(4) + assert_cursor_max(4) + assert_line('def ') + input_keys("\M-\C-y", false) + assert_byte_pointer_size('hoge') + assert_cursor(4) + assert_cursor_max(4) + assert_line('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/