[ruby/irb] Remove KEYWORD_ALIASES which handled special alias name

of irb_break irb_catch and irb_next command
(https://github.com/ruby/irb/pull/1004)

* Remove KEYWORD_ALIASES which handled special alias name of irb_break irb_catch and irb_next command

* Remove unused instance variable user_aliases

Co-authored-by: Stan Lo <stan001212@gmail.com>

---------

https://github.com/ruby/irb/commit/f256d7899f

Co-authored-by: Stan Lo <stan001212@gmail.com>
This commit is contained in:
tomoya ishida 2024-09-13 00:04:33 +09:00 committed by git
parent fcb058309b
commit a542479a75
3 changed files with 11 additions and 17 deletions

View File

@ -39,7 +39,7 @@ module IRB
help_cmds = commands_grouped_by_categories.delete("Help")
no_category_cmds = commands_grouped_by_categories.delete("No category")
aliases = irb_context.instance_variable_get(:@user_aliases).map do |alias_name, target|
aliases = irb_context.instance_variable_get(:@command_aliases).map do |alias_name, target|
{ display_name: alias_name, description: "Alias for `#{target}`" }
end

View File

@ -149,8 +149,7 @@ module IRB
@newline_before_multiline_output = true
end
@user_aliases = IRB.conf[:COMMAND_ALIASES].dup
@command_aliases = @user_aliases.merge(KEYWORD_ALIASES)
@command_aliases = IRB.conf[:COMMAND_ALIASES].dup
end
private def term_interactive?
@ -158,17 +157,6 @@ module IRB
STDIN.tty? && ENV['TERM'] != 'dumb'
end
# because all input will eventually be evaluated as Ruby code,
# command names that conflict with Ruby keywords need special workaround
# we can remove them once we implemented a better command system for IRB
KEYWORD_ALIASES = {
:break => :irb_break,
:catch => :irb_catch,
:next => :irb_next,
}.freeze
private_constant :KEYWORD_ALIASES
def use_tracer=(val)
require_relative "ext/tracer" if val
IRB.conf[:USE_TRACER] = val

View File

@ -181,9 +181,15 @@ module IRB
[:edit, NO_OVERRIDE]
)
_register_with_aliases(:irb_break, Command::Break)
_register_with_aliases(:irb_catch, Command::Catch)
_register_with_aliases(:irb_next, Command::Next)
_register_with_aliases(:irb_break, Command::Break,
[:break, OVERRIDE_ALL]
)
_register_with_aliases(:irb_catch, Command::Catch,
[:catch, OVERRIDE_PRIVATE_ONLY]
)
_register_with_aliases(:irb_next, Command::Next,
[:next, OVERRIDE_ALL]
)
_register_with_aliases(:irb_delete, Command::Delete,
[:delete, NO_OVERRIDE]
)