[ruby/irb] Change context-mode's default to new mode 4.

This new mode uses a copy of the TOPLEVEL_BINDING. This is compatible with refinements (contrary to mode 3), while keeping nested IRB sessions separate

https://github.com/ruby/irb/commit/25c731cb2f
This commit is contained in:
Marc-Andre Lafortune 2020-11-20 16:58:02 -05:00 committed by aycabta
parent 753222d72c
commit 980f994b3b
2 changed files with 4 additions and 2 deletions

View File

@ -108,7 +108,7 @@ module IRB # :nodoc:
@CONF[:PROMPT_MODE] = (STDIN.tty? ? :DEFAULT : :NULL)
@CONF[:AUTO_INDENT] = true
@CONF[:CONTEXT_MODE] = 3 # use binding in function on TOPLEVEL_BINDING
@CONF[:CONTEXT_MODE] = 4 # use a copy of TOPLEVEL_BINDING
@CONF[:SINGLE_IRB] = false
@CONF[:LC_MESSAGES] = Locale.new

View File

@ -51,11 +51,13 @@ EOF
end
@binding = BINDING_QUEUE.pop
when 3 # binding in function on TOPLEVEL_BINDING(default)
when 3 # binding in function on TOPLEVEL_BINDING
@binding = eval("self.class.remove_method(:irb_binding) if defined?(irb_binding); private; def irb_binding; binding; end; irb_binding",
TOPLEVEL_BINDING,
__FILE__,
__LINE__ - 3)
when 4 # binding is a copy of TOPLEVEL_BINDING (default)
@binding = TOPLEVEL_BINDING.dup
end
end