summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2021-08-15 17:08:58 +0900
committeraycabta <aycabta@gmail.com>2021-08-29 20:30:32 +0900
commite66200780b5a07c070295231408873c8d3dd7c5e (patch)
treebcb164d7153c4732639f41f656b13ab249aa311d
parenteadd25d5afa8eef4c0876e897e0f55c5fcad9951 (diff)
downloadruby-e66200780b5a07c070295231408873c8d3dd7c5e.tar.gz
[ruby/reline] Separate calling completion proc with checking args
https://github.com/ruby/reline/commit/3203cb97db
-rw-r--r--lib/reline/line_editor.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 97f12116b9..0b5b6831dc 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -1165,7 +1165,13 @@ class Reline::LineEditor
def call_completion_proc
result = retrieve_completion_block(true)
- preposing, target, postposing = result
+ pre, target, post = result
+ result = call_completion_proc_with_checking_args(pre, target, post)
+ Reline.core.instance_variable_set(:@completion_quote_character, nil)
+ result
+ end
+
+ private def call_completion_proc_with_checking_args(pre, target, post)
if @completion_proc and target
argnum = @completion_proc.parameters.inject(0) { |result, item|
case item.first
@@ -1179,12 +1185,11 @@ class Reline::LineEditor
when 1
result = @completion_proc.(target)
when 2
- result = @completion_proc.(target, preposing)
+ result = @completion_proc.(target, pre)
when 3..Float::INFINITY
- result = @completion_proc.(target, preposing, postposing)
+ result = @completion_proc.(target, pre, post)
end
end
- Reline.core.instance_variable_set(:@completion_quote_character, nil)
result
end