[前][次][番号順一覧][スレッド一覧]

ruby-changes:55914

From: Takashi <ko1@a...>
Date: Thu, 30 May 2019 15:50:39 +0900 (JST)
Subject: [ruby-changes:55914] Takashi Kokubun: 70e87d9660 (trunk): Do not rely on IRB.conf[:MAIN_CONTEXT] before initialize

https://git.ruby-lang.org/ruby.git/commit/?id=70e87d9660

From 70e87d9660af24fb93cac1312b6e1990602c1396 Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Thu, 30 May 2019 15:49:48 +0900
Subject: Do not rely on IRB.conf[:MAIN_CONTEXT] before initialize

so that we can colorize binding.irb source lines.

diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb
index 9337c17..2bbd5cf 100644
--- a/lib/irb/workspace.rb
+++ b/lib/irb/workspace.rb
@@ -131,7 +131,10 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/irb/workspace.rb#L131
           return
         end
       end
-      if IRB.conf&.fetch(:MAIN_CONTEXT, nil)&.use_colorize?
+
+      # NOT using #use_colorize? of IRB.conf[:MAIN_CONTEXT] because this method may be called before IRB::Irb#run
+      use_colorize = IRB.conf.fetch(:USE_COLORIZE, true)
+      if use_colorize
         lines = Color.colorize_code(code).lines
       else
         lines = code.lines
@@ -141,7 +144,7 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/irb/workspace.rb#L144
       start_pos = [pos - 5, 0].max
       end_pos   = [pos + 5, lines.size - 1].min
 
-      if IRB.conf&.fetch(:MAIN_CONTEXT, nil)&.use_colorize?
+      if use_colorize
         fmt = " %2s #{Color.colorize("%#{end_pos.to_s.length}d", [:BLUE, :BOLD])}: %s"
       else
         fmt = " %2s %#{end_pos.to_s.length}d: %s"
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]