diff options
author | tomoya ishida <tomoyapenguin@gmail.com> | 2023-11-22 21:06:19 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-11-22 12:06:25 +0000 |
commit | ea60bf912caa3ea193b7673b59b0113c1e708609 (patch) | |
tree | a469cf3b9b15c9553fc9068a8bdaf5f93b4a069e /lib/irb | |
parent | 9ae6ee5a59e74e629f73222938b53a6eae8d2ded (diff) | |
download | ruby-ea60bf912caa3ea193b7673b59b0113c1e708609.tar.gz |
[ruby/irb] Rescue Exception, ignore warning in completion
doc_namespace
(https://github.com/ruby/irb/pull/777)
https://github.com/ruby/irb/commit/c2f671611a
Diffstat (limited to 'lib/irb')
-rw-r--r-- | lib/irb/type_completion/completor.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/irb/type_completion/completor.rb b/lib/irb/type_completion/completor.rb index e893fd8adc..df1e1c7790 100644 --- a/lib/irb/type_completion/completor.rb +++ b/lib/irb/type_completion/completor.rb @@ -26,8 +26,8 @@ module IRB 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) @@ -36,8 +36,7 @@ module IRB 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 @@ -45,6 +44,7 @@ module IRB 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 } @@ -102,6 +102,11 @@ module IRB end else end + rescue Exception => e + handle_error(e) + nil + ensure + $VERBOSE = verbose end def candidates_from_result(result) @@ -229,6 +234,7 @@ module IRB end def handle_error(e) + Completor.last_completion_error = e end end end |