Skip to content

Commit 6a519e9

Browse files
Replace gsub with rstrip (#1095)
The regular expression ``/\s*\z/`` matches any whitespace characters at end of string, which means only one match is possible with ``gsub``, replacing it with an empty string. The same can be achieved by ``String#rstrip``.
1 parent e91b21f commit 6a519e9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/irb/completion.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def complete_require_path(target, preposing, postposing)
159159
else
160160
return nil # It's not String literal
161161
end
162-
tokens = RubyLex.ripper_lex_without_warning(preposing.gsub(/\s*\z/, ''))
162+
tokens = RubyLex.ripper_lex_without_warning(preposing.rstrip)
163163
tok = nil
164164
tokens.reverse_each do |t|
165165
unless [:on_lparen, :on_sp, :on_ignored_sp, :on_nl, :on_ignored_nl, :on_comment].include?(t.event)

0 commit comments

Comments
 (0)