summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-10-17 23:00:23 -0700
committergit <svn-admin@ruby-lang.org>2022-10-18 06:03:23 +0000
commit931bcd1b6315de5407a73019482bd3919f16820d (patch)
treebe602a151c5c8137e075293b58b780608801c926
parenta09f764ce52838a363b006ea434287eca431dbae (diff)
[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
-rw-r--r--lib/irb/color.rb6
1 files 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