summaryrefslogtreecommitdiff
path: root/lib/irb/completion.rb
diff options
context:
space:
mode:
authortomoya ishida <[email protected]>2023-10-13 01:54:04 +0900
committergit <[email protected]>2023-10-12 16:54:09 +0000
commit1126bd8c65ab077392b559fedd8f9b07303313c9 (patch)
treeab62eb78fb3fafee3c2767ffa4306266e627667a /lib/irb/completion.rb
parent10ba3fc302d68f977ce958b27a46ce0dab537f0c (diff)
[ruby/irb] Fix require path completion disturbing string method
completion (https://github.com/ruby/irb/pull/726) https://github.com/ruby/irb/commit/e42dc74ce0
Diffstat (limited to 'lib/irb/completion.rb')
-rw-r--r--lib/irb/completion.rb32
1 files changed, 15 insertions, 17 deletions
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:)