From 931bcd1b6315de5407a73019482bd3919f16820d Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 17 Oct 2022 23:00:23 -0700 Subject: [PATCH] [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: 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