mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 13:34:17 +02:00
[ruby/irb] Allow non-identifier aliases like Pry's @ and $
(https://github.com/ruby/irb/pull/426)
* Allow non-identifier aliases
* Move the configuration to IRB.conf
* Avoid abusing method lookup for symbol aliases
* Add more alias tests
* A small optimization
* Assume non-nil Context
* Load IRB.conf earlier
e23db5132e
This commit is contained in:
parent
d24ac6d281
commit
a13836e70d
5 changed files with 87 additions and 0 deletions
|
@ -65,6 +65,12 @@ class RubyLex
|
|||
false
|
||||
end
|
||||
else
|
||||
# Accept any single-line input starting with a non-identifier alias (ex: @, $)
|
||||
command = code.split(/\s/, 2).first
|
||||
if context.symbol_alias(command)
|
||||
next true
|
||||
end
|
||||
|
||||
code.gsub!(/\s*\z/, '').concat("\n")
|
||||
ltype, indent, continue, code_block_open = check_state(code, context: context)
|
||||
if ltype or indent > 0 or continue or code_block_open
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue