Skip to content

Commit 3203cb9

Browse files
committed
Separate calling completion proc with checking args
1 parent d18d86b commit 3203cb9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/reline/line_editor.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,13 @@ def input_key(key)
11651165

11661166
def call_completion_proc
11671167
result = retrieve_completion_block(true)
1168-
preposing, target, postposing = result
1168+
pre, target, post = result
1169+
result = call_completion_proc_with_checking_args(pre, target, post)
1170+
Reline.core.instance_variable_set(:@completion_quote_character, nil)
1171+
result
1172+
end
1173+
1174+
private def call_completion_proc_with_checking_args(pre, target, post)
11691175
if @completion_proc and target
11701176
argnum = @completion_proc.parameters.inject(0) { |result, item|
11711177
case item.first
@@ -1179,12 +1185,11 @@ def call_completion_proc
11791185
when 1
11801186
result = @completion_proc.(target)
11811187
when 2
1182-
result = @completion_proc.(target, preposing)
1188+
result = @completion_proc.(target, pre)
11831189
when 3..Float::INFINITY
1184-
result = @completion_proc.(target, preposing, postposing)
1190+
result = @completion_proc.(target, pre, post)
11851191
end
11861192
end
1187-
Reline.core.instance_variable_set(:@completion_quote_character, nil)
11881193
result
11891194
end
11901195

0 commit comments

Comments
 (0)