summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2020-11-14 22:52:38 +0900
committeraycabta <aycabta@gmail.com>2020-12-05 02:58:58 +0900
commitc85035363feb79d283a753db1fe795fff0067213 (patch)
tree555cb971b13f0900296a9f2de6ab0b5a64fd0f82 /lib
parent21f26018d253bf1320432a956a9ce7dfa8ab7adb (diff)
[ruby/reline] Key strokes like 2dl should behave d2l
Key strokes, vi arg, operator, and motion should be treated as operator, vi arg, and motion. https://github.com/ruby/reline/commit/d1a7e74aa4
Diffstat (limited to 'lib')
-rw-r--r--lib/reline/line_editor.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index ea1c913ee9..c7b4e47ddb 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -179,6 +179,7 @@ class Reline::LineEditor
@vi_arg = nil
@waiting_proc = nil
@waiting_operator_proc = nil
+ @waiting_operator_vi_arg = nil
@completion_journey_data = nil
@completion_state = CompletionState::NORMAL
@perfect_matched = nil
@@ -698,6 +699,7 @@ class Reline::LineEditor
if @waiting_operator_proc
if VI_MOTIONS.include?(method_symbol)
old_cursor, old_byte_pointer = @cursor, @byte_pointer
+ @vi_arg = @waiting_operator_vi_arg if @waiting_operator_vi_arg > 1
block.(true)
unless @waiting_proc
cursor_diff, byte_pointer_diff = @cursor - old_cursor, @byte_pointer - old_byte_pointer
@@ -721,6 +723,8 @@ class Reline::LineEditor
block.(false)
end
@waiting_operator_proc = nil
+ @waiting_operator_vi_arg = nil
+ @vi_arg = nil
else
block.(false)
end
@@ -2088,7 +2092,7 @@ class Reline::LineEditor
@cursor = 0
end
- private def vi_change_meta(key)
+ private def vi_change_meta(key, arg: 1)
@waiting_operator_proc = proc { |cursor_diff, byte_pointer_diff|
if byte_pointer_diff > 0
@line, cut = byteslice!(@line, @byte_pointer, byte_pointer_diff)
@@ -2101,9 +2105,10 @@ class Reline::LineEditor
@byte_pointer += byte_pointer_diff if byte_pointer_diff < 0
@config.editing_mode = :vi_insert
}
+ @waiting_operator_vi_arg = arg
end
- private def vi_delete_meta(key)
+ private def vi_delete_meta(key, arg: 1)
@waiting_operator_proc = proc { |cursor_diff, byte_pointer_diff|
if byte_pointer_diff > 0
@line, cut = byteslice!(@line, @byte_pointer, byte_pointer_diff)
@@ -2115,9 +2120,10 @@ class Reline::LineEditor
@cursor_max -= cursor_diff.abs
@byte_pointer += byte_pointer_diff if byte_pointer_diff < 0
}
+ @waiting_operator_vi_arg = arg
end
- private def vi_yank(key)
+ private def vi_yank(key, arg: 1)
@waiting_operator_proc = proc { |cursor_diff, byte_pointer_diff|
if byte_pointer_diff > 0
cut = @line.byteslice(@byte_pointer, byte_pointer_diff)
@@ -2126,6 +2132,7 @@ class Reline::LineEditor
end
copy_for_vi(cut)
}
+ @waiting_operator_vi_arg = arg
end
private def vi_list_or_eof(key)