[ruby/reline] Use unix_line_discard when Ctrl-u is entered

The kill-line was called when C-u was entered, so it is now called unix-line-discard.

In readline(3):

> unix-line-discard (C-u)
>               Kill backward from point to the beginning of the line.
>               The killed text is saved on the kill-ring.

https://github.com/ruby/reline/commit/27570d195e
This commit is contained in:
ima1zumi 2021-12-30 11:16:15 +09:00 committed by git
parent 8727161fcf
commit f589242e75
2 changed files with 23 additions and 1 deletions

View File

@ -43,7 +43,7 @@ class Reline::KeyActor::Emacs < Reline::KeyActor::Base
# 20 ^T
:ed_transpose_chars,
# 21 ^U
:ed_kill_line,
:unix_line_discard,
# 22 ^V
:ed_quoted_insert,
# 23 ^W

View File

@ -2329,4 +2329,26 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
assert_cursor(1)
assert_cursor_max(1)
end
def test_unix_line_discard
input_keys("\C-u", false)
assert_byte_pointer_size('')
assert_cursor(0)
assert_cursor_max(0)
assert_line('')
input_keys('abc')
assert_byte_pointer_size('abc')
assert_cursor(3)
assert_cursor_max(3)
input_keys("\C-b\C-u", false)
assert_byte_pointer_size('')
assert_cursor(0)
assert_cursor_max(1)
assert_line('c')
input_keys("\C-f\C-u", false)
assert_byte_pointer_size('')
assert_cursor(0)
assert_cursor_max(0)
assert_line('')
end
end