Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/irb/command/help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def help_message

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

Expand Down
13 changes: 1 addition & 12 deletions lib/irb/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,25 +150,14 @@ def initialize(irb, workspace = nil, input_method = nil)
end

@user_aliases = IRB.conf[:COMMAND_ALIASES].dup
tompng marked this conversation as resolved.
Show resolved Hide resolved
@command_aliases = @user_aliases.merge(KEYWORD_ALIASES)
@command_aliases = @user_aliases.dup
tompng marked this conversation as resolved.
Show resolved Hide resolved
end

private def term_interactive?
return true if ENV['TEST_IRB_FORCE_INTERACTIVE']
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
Expand Down
12 changes: 9 additions & 3 deletions lib/irb/default_commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,15 @@ def load_command(command)
[: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]
)
Expand Down
Loading