[ruby/reline] Yank by em-kill-region correctly

This closes ruby/reline#106.

https://github.com/ruby/reline/commit/2549a52e15
This commit is contained in:
aycabta 2020-12-18 23:36:33 +09:00
Родитель af2c81e10c
Коммит d4257c6152
2 изменённых файлов: 21 добавлений и 1 удалений

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

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

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

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