summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2020-12-18 23:35:15 +0900
committeraycabta <aycabta@gmail.com>2020-12-19 02:12:11 +0900
commitaf2c81e10c15c267611e59f11b7152545c617826 (patch)
treee02bc8cb69d4ca1c6a208e886f920a5be1f178eb
parent671f2762fb8a4832d2c17322ee600f53c91f76f5 (diff)
[ruby/reline] Bind yank-pop correctly
https://github.com/ruby/reline/commit/3c74beac65
-rw-r--r--lib/reline/key_actor/emacs.rb2
-rw-r--r--lib/reline/line_editor.rb2
-rw-r--r--test/reline/test_key_actor_emacs.rb18
3 files changed, 21 insertions, 1 deletions
diff --git a/lib/reline/key_actor/emacs.rb b/lib/reline/key_actor/emacs.rb
index 1e51d4fa18..cad97a7d04 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
# 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 b80a184fc6..dc1f8824a2 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -1991,6 +1991,7 @@ class Reline::LineEditor
@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
@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 5ec8be6621..2ba6a32b93 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
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')