Skip to content

Commit c2f6716

Browse files
authored
Rescue Exception, ignore warning in completion doc_namespace (#777)
1 parent 997df3e commit c2f6716

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/irb/type_completion/completor.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def inspect
2626
end
2727

2828
def completion_candidates(preposing, target, _postposing, bind:)
29-
@preposing = preposing
3029
verbose, $VERBOSE = $VERBOSE, nil
30+
@preposing = preposing
3131
code = "#{preposing}#{target}"
3232
@result = analyze code, bind
3333
name, candidates = candidates_from_result(@result)
@@ -36,15 +36,15 @@ def completion_candidates(preposing, target, _postposing, bind:)
3636
candidates.map(&:to_s).select { !_1.match?(all_symbols_pattern) && _1.start_with?(name) }.uniq.sort.map do
3737
target + _1[name.size..]
3838
end
39-
rescue SyntaxError, StandardError => e
40-
Completor.last_completion_error = e
39+
rescue Exception => e
4140
handle_error(e)
4241
[]
4342
ensure
4443
$VERBOSE = verbose
4544
end
4645

4746
def doc_namespace(preposing, matched, postposing, bind:)
47+
verbose, $VERBOSE = $VERBOSE, nil
4848
name = matched[/[a-zA-Z_0-9]*[!?=]?\z/]
4949
method_doc = -> type do
5050
type = type.types.find { _1.all_methods.include? name.to_sym }
@@ -102,6 +102,11 @@ def doc_namespace(preposing, matched, postposing, bind:)
102102
end
103103
else
104104
end
105+
rescue Exception => e
106+
handle_error(e)
107+
nil
108+
ensure
109+
$VERBOSE = verbose
105110
end
106111

107112
def candidates_from_result(result)
@@ -229,6 +234,7 @@ def find_target(node, position)
229234
end
230235

231236
def handle_error(e)
237+
Completor.last_completion_error = e
232238
end
233239
end
234240
end

0 commit comments

Comments
 (0)