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

ruby-changes:74074

From: Takashi <ko1@a...>
Date: Tue, 18 Oct 2022 15:03:38 +0900 (JST)
Subject: [ruby-changes:74074] 931bcd1b63 (master): [ruby/irb] Assert lvars_code doesn't include \n

https://git.ruby-lang.org/ruby.git/commit/?id=931bcd1b63

From 931bcd1b6315de5407a73019482bd3919f16820d Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Mon, 17 Oct 2022 23:00:23 -0700
Subject: [ruby/irb] Assert lvars_code doesn't include \n

Removing /\A.+\n/ could have an unexpected impact, depending on how
RubyLex.generate_local_variables_assign_code is implemented. It feels
like a too much assumption and the intention isn't immediately clear,
so I added these changes.

https://github.com/ruby/irb/commit/ccc07a35ce
---
 lib/irb/color.rb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/irb/color.rb b/lib/irb/color.rb
index 34912420e4..6378e14856 100644
--- a/lib/irb/color.rb
+++ b/lib/irb/color.rb
@@ -156,10 +156,10 @@ module IRB # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/irb/color.rb#L156
         end
 
         if lvars_code
-          colored.sub(/\A.+\n/, '')
-        else
-          colored
+          raise "#{lvars_code.dump} should have no \\n" if lvars_code.include?("\n")
+          colored.sub!(/\A.+\n/, '') # delete_prefix lvars_code with colors
         end
+        colored
       end
 
       private
-- 
cgit v1.2.3


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

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