summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2020-11-02 14:48:44 +0900
committeraycabta <aycabta@gmail.com>2020-12-05 02:58:58 +0900
commitfaf8f216be034a575350c7f3387992930b224bfc (patch)
tree80b7619be8eb0561cdbda37b37b46aa987145f83
parent564aadce626ff8dc94784d909d2a9c7bcd27b427 (diff)
[ruby/reline] Keep operator proc as a local variable in the scope
The proc variable will be used later so the instance variable will be changes. https://github.com/ruby/reline/commit/496c4361f6
-rw-r--r--lib/reline/line_editor.rb3
-rw-r--r--test/reline/test_key_actor_vi.rb13
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index fde8ad928f..17fabd175d 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -706,12 +706,13 @@ class Reline::LineEditor
else
old_waiting_proc = @waiting_proc
old_waiting_operator_proc = @waiting_operator_proc
+ current_waiting_operator_proc = @waiting_operator_proc
@waiting_proc = proc { |k|
old_cursor, old_byte_pointer = @cursor, @byte_pointer
old_waiting_proc.(k)
cursor_diff, byte_pointer_diff = @cursor - old_cursor, @byte_pointer - old_byte_pointer
@cursor, @byte_pointer = old_cursor, old_byte_pointer
- @waiting_operator_proc.(cursor_diff, byte_pointer_diff)
+ current_waiting_operator_proc.(cursor_diff, byte_pointer_diff)
@waiting_operator_proc = old_waiting_operator_proc
}
end
diff --git a/test/reline/test_key_actor_vi.rb b/test/reline/test_key_actor_vi.rb
index c6337baea7..c09c93691a 100644
--- a/test/reline/test_key_actor_vi.rb
+++ b/test/reline/test_key_actor_vi.rb
@@ -1215,6 +1215,19 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase
assert_line('aaa ddd eee')
end
+ def test_vi_delete_meta_with_vi_next_char
+ input_keys("aaa bbb ccc ___ ddd\C-[02w")
+ assert_byte_pointer_size('aaa bbb ')
+ assert_cursor(8)
+ assert_cursor_max(19)
+ assert_line('aaa bbb ccc ___ ddd')
+ input_keys('df_')
+ assert_byte_pointer_size('aaa bbb ')
+ assert_cursor(8)
+ assert_cursor_max(15)
+ assert_line('aaa bbb ___ ddd')
+ end
+
def test_vi_change_meta
input_keys("aaa bbb ccc ddd eee\C-[02w")
assert_byte_pointer_size('aaa bbb ')