From 1126bd8c65ab077392b559fedd8f9b07303313c9 Mon Sep 17 00:00:00 2001 From: tomoya ishida Date: Fri, 13 Oct 2023 01:54:04 +0900 Subject: [ruby/irb] Fix require path completion disturbing string method completion (https://github.com/ruby/irb/pull/726) https://github.com/ruby/irb/commit/e42dc74ce0 --- lib/irb/completion.rb | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'lib') diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb index 26215f6fe1..795a35bb2d 100644 --- a/lib/irb/completion.rb +++ b/lib/irb/completion.rb @@ -132,24 +132,22 @@ module IRB break end end - result = [] - if tok && tok.event == :on_ident && tok.state == Ripper::EXPR_CMDARG - case tok.tok - when 'require' - result = retrieve_files_to_require_from_load_path.select { |path| - path.start_with?(actual_target) - }.map { |path| - quote + path - } - when 'require_relative' - result = retrieve_files_to_require_relative_from_current_dir.select { |path| - path.start_with?(actual_target) - }.map { |path| - quote + path - } - end + return unless tok&.event == :on_ident && tok.state == Ripper::EXPR_CMDARG + + case tok.tok + when 'require' + retrieve_files_to_require_from_load_path.select { |path| + path.start_with?(actual_target) + }.map { |path| + quote + path + } + when 'require_relative' + retrieve_files_to_require_relative_from_current_dir.select { |path| + path.start_with?(actual_target) + }.map { |path| + quote + path + } end - result end def completion_candidates(preposing, target, postposing, bind:) -- cgit v1.2.3