[前][次][番号順一覧][スレッド一覧]

ruby-changes:59715

From: aycabta <ko1@a...>
Date: Fri, 17 Jan 2020 01:37:32 +0900 (JST)
Subject: [ruby-changes:59715] 800c2a8e4c (master): Implement vi_insert_at_bol and vi_add_at_eol

https://git.ruby-lang.org/ruby.git/commit/?id=800c2a8e4c

From 800c2a8e4c4b644aca4bede913d492c25ba304c1 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Fri, 17 Jan 2020 01:35:13 +0900
Subject: Implement vi_insert_at_bol and vi_add_at_eol


diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index dda602e..1387bfa 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -1890,6 +1890,16 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L1890
     end
   end
 
+  private def vi_insert_at_bol(key)
+    ed_move_to_beg(key)
+    @config.editing_mode = :vi_insert
+  end
+
+  private def vi_add_at_eol(key)
+    ed_move_to_end(key)
+    @config.editing_mode = :vi_insert
+  end
+
   private def ed_delete_prev_char(key, arg: 1)
     deleted = ''
     arg.times do
diff --git a/test/reline/test_key_actor_vi.rb b/test/reline/test_key_actor_vi.rb
index d46d784..b8ab160 100644
--- a/test/reline/test_key_actor_vi.rb
+++ b/test/reline/test_key_actor_vi.rb
@@ -56,6 +56,42 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase https://github.com/ruby/ruby/blob/trunk/test/reline/test_key_actor_vi.rb#L56
     assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
   end
 
+  def test_vi_insert_at_bol
+    input_keys('I')
+    assert_line('I')
+    assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
+    input_keys("12345\C-[hh")
+    assert_line('I12345')
+    assert_byte_pointer_size('I12')
+    assert_cursor(3)
+    assert_cursor_max(6)
+    assert_instance_of(Reline::KeyActor::ViCommand, @config.editing_mode)
+    input_keys('I')
+    assert_line('I12345')
+    assert_byte_pointer_size('')
+    assert_cursor(0)
+    assert_cursor_max(6)
+    assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
+  end
+
+  def test_vi_add_at_eol
+    input_keys('A')
+    assert_line('A')
+    assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
+    input_keys("12345\C-[hh")
+    assert_line('A12345')
+    assert_byte_pointer_size('A12')
+    assert_cursor(3)
+    assert_cursor_max(6)
+    assert_instance_of(Reline::KeyActor::ViCommand, @config.editing_mode)
+    input_keys('A')
+    assert_line('A12345')
+    assert_byte_pointer_size('A12345')
+    assert_cursor(6)
+    assert_cursor_max(6)
+    assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
+  end
+
   def test_ed_insert_one
     input_keys('a')
     assert_line('a')
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]