ruby-changes:70536
From: aycabta <ko1@a...>
Date: Fri, 24 Dec 2021 18:23:06 +0900 (JST)
Subject: [ruby-changes:70536] 6c3cc9c58a (master): [ruby/reline] Rename the wrong name "em-kill-line" with the correct name "unix-line-discard"
https://git.ruby-lang.org/ruby.git/commit/?id=6c3cc9c58a From 6c3cc9c58ab95e963d6255d719e2248cafef7b49 Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Mon, 27 Sep 2021 03:58:19 +0900 Subject: [ruby/reline] Rename the wrong name "em-kill-line" with the correct name "unix-line-discard" https://github.com/ruby/reline/commit/da7af35d1f --- lib/reline/line_editor.rb | 10 +++++----- test/reline/test_key_actor_vi.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 20032315b77..a1f12f2cfab 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -2616,11 +2616,12 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L2616 end alias_method :kill_line, :ed_kill_line - # Editline:: +em-kill-line+ (not bound) Delete the entire contents of the - # edit buffer and save it to the cut buffer. +vi-kill-line-prev+ + # Editline:: +vi-kill-line-prev+ (vi: +Ctrl-U+) Delete the string from the + # beginning of the edit buffer to the cursor and save it to the + # cut buffer. # GNU Readline:: +unix-line-discard+ (+C-u+) Kill backward from the cursor # to the beginning of the current line. - private def em_kill_line(key) + private def vi_kill_line_prev(key) if @byte_pointer > 0 @line, deleted = byteslice!(@line, 0, @byte_pointer) @byte_pointer = 0 @@ -2629,8 +2630,7 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L2630 @cursor = 0 end end - alias_method :unix_line_discard, :em_kill_line - alias_method :vi_kill_line_prev, :em_kill_line + alias_method :unix_line_discard, :vi_kill_line_prev private def em_delete(key) if (not @is_multiline and @line.empty?) or (@is_multiline and @line.empty? and @buffer_of_lines.size == 1) diff --git a/test/reline/test_key_actor_vi.rb b/test/reline/test_key_actor_vi.rb index 722cdc0b75f..b3d49c9bbb2 100644 --- a/test/reline/test_key_actor_vi.rb +++ b/test/reline/test_key_actor_vi.rb @@ -1426,4 +1426,32 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase https://github.com/ruby/ruby/blob/trunk/test/reline/test_key_actor_vi.rb#L1426 assert_cursor(4) assert_cursor_max(4) end + + def test_vi_kill_line_prev + 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-u", false) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(0) + assert_line('') + input_keys('abc') + input_keys("\C-[\C-u", false) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(1) + assert_line('c') + input_keys("\C-u", false) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(1) + assert_line('c') + end end -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/