ruby-changes:59465
From: aycabta <ko1@a...>
Date: Wed, 25 Dec 2019 09:34:33 +0900 (JST)
Subject: [ruby-changes:59465] 622e47a1db (master): ^D on non-empty line in vi mode behaves like Enter
https://git.ruby-lang.org/ruby.git/commit/?id=622e47a1db From 622e47a1dbeee52fb218b816943b69cb88e17ae6 Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Wed, 25 Dec 2019 09:29:46 +0900 Subject: ^D on non-empty line in vi mode behaves like Enter diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 721d50b..d668da7 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1938,9 +1938,11 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L1938 @eof = true finish else - # TODO: list + ed_newline(key) end end + alias_method :vi_end_of_transmission, :vi_list_or_eof + alias_method :vi_eof_maybe, :vi_list_or_eof private def ed_delete_next_char(key, arg: 1) byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer) diff --git a/test/reline/test_key_actor_vi.rb b/test/reline/test_key_actor_vi.rb index dc5030c..1ea160b 100644 --- a/test/reline/test_key_actor_vi.rb +++ b/test/reline/test_key_actor_vi.rb @@ -812,16 +812,19 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase https://github.com/ruby/ruby/blob/trunk/test/reline/test_key_actor_vi.rb#L812 end def test_vi_list_or_eof - input_keys('a') - assert_byte_pointer_size('a') - assert_cursor(1) - assert_cursor_max(1) + input_keys("\C-d") # quit from inputing + assert_line(nil) + assert(@line_editor.finished?) + end + + def test_vi_list_or_eof_with_non_empty_line + input_keys('ab') + assert_byte_pointer_size('ab') + assert_cursor(2) + assert_cursor_max(2) refute(@line_editor.finished?) input_keys("\C-d") - assert_line('a') - refute(@line_editor.finished?) - input_keys("\C-h\C-d") - assert_line(nil) + assert_line('ab') assert(@line_editor.finished?) end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/