From f589242e750939eecf2a140fa3182dc5e387f157 Mon Sep 17 00:00:00 2001 From: ima1zumi Date: Thu, 30 Dec 2021 11:16:15 +0900 Subject: [PATCH] [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 --- lib/reline/key_actor/emacs.rb | 2 +- test/reline/test_key_actor_emacs.rb | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/reline/key_actor/emacs.rb b/lib/reline/key_actor/emacs.rb index 86e39b705c..a561feee57 100644 --- a/lib/reline/key_actor/emacs.rb +++ b/lib/reline/key_actor/emacs.rb @@ -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 diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb index a5fdf247c8..40b26e5058 100644 --- a/test/reline/test_key_actor_emacs.rb +++ b/test/reline/test_key_actor_emacs.rb @@ -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