Skip to content

Commit

Permalink
[ruby/reline] Use unix_line_discard when Ctrl-u is entered
Browse files Browse the repository at this point in the history
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.

ruby/reline@27570d195e
  • Loading branch information
ima1zumi authored and matzbot committed Dec 30, 2021
1 parent 8727161 commit f589242
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/reline/key_actor/emacs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions test/reline/test_key_actor_emacs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2329,4 +2329,26 @@ def test_input_unknown_char
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

0 comments on commit f589242

Please sign in to comment.