Skip to content

Commit

Permalink
Rescue Exception, ignore warning in completion doc_namespace (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng authored Nov 22, 2023
1 parent 997df3e commit c2f6716
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/irb/type_completion/completor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def inspect
end

def completion_candidates(preposing, target, _postposing, bind:)
@preposing = preposing
verbose, $VERBOSE = $VERBOSE, nil
@preposing = preposing
code = "#{preposing}#{target}"
@result = analyze code, bind
name, candidates = candidates_from_result(@result)
Expand All @@ -36,15 +36,15 @@ def completion_candidates(preposing, target, _postposing, bind:)
candidates.map(&:to_s).select { !_1.match?(all_symbols_pattern) && _1.start_with?(name) }.uniq.sort.map do
target + _1[name.size..]
end
rescue SyntaxError, StandardError => e
Completor.last_completion_error = e
rescue Exception => e
handle_error(e)
[]
ensure
$VERBOSE = verbose
end

def doc_namespace(preposing, matched, postposing, bind:)
verbose, $VERBOSE = $VERBOSE, nil
name = matched[/[a-zA-Z_0-9]*[!?=]?\z/]
method_doc = -> type do
type = type.types.find { _1.all_methods.include? name.to_sym }
Expand Down Expand Up @@ -102,6 +102,11 @@ def doc_namespace(preposing, matched, postposing, bind:)
end
else
end
rescue Exception => e
handle_error(e)
nil
ensure
$VERBOSE = verbose
end

def candidates_from_result(result)
Expand Down Expand Up @@ -229,6 +234,7 @@ def find_target(node, position)
end

def handle_error(e)
Completor.last_completion_error = e
end
end
end
Expand Down

0 comments on commit c2f6716

Please sign in to comment.