[ruby/reline] Bind yank-pop correctly

https://github.com/ruby/reline/commit/3c74beac65
This commit is contained in:
aycabta 2020-12-18 23:35:15 +09:00
Родитель 671f2762fb
Коммит af2c81e10c
3 изменённых файлов: 21 добавлений и 1 удалений

Просмотреть файл

@ -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-^[

Просмотреть файл

@ -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

Просмотреть файл

@ -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')