ruby-changes:64246
From: Marc-Andre <ko1@a...>
Date: Thu, 17 Dec 2020 20:24:55 +0900 (JST)
Subject: [ruby-changes:64246] 980f994b3b (master): [ruby/irb] Change context-mode's default to new mode 4.
https://git.ruby-lang.org/ruby.git/commit/?id=980f994b3b From 980f994b3b349486c5e64b51241330d4c9fc63f1 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune <github@m...> Date: Fri, 20 Nov 2020 16:58:02 -0500 Subject: [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 diff --git a/lib/irb/init.rb b/lib/irb/init.rb index 48b669f..73ef420 100644 --- a/lib/irb/init.rb +++ b/lib/irb/init.rb @@ -108,7 +108,7 @@ module IRB # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/irb/init.rb#L108 @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 diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb index 97d3c5f..5a3a4bc 100644 --- a/lib/irb/workspace.rb +++ b/lib/irb/workspace.rb @@ -51,11 +51,13 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/irb/workspace.rb#L51 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/