Skip to content

Commit

Permalink
Assert lvars_code doesn't include \n
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
k0kubun committed Oct 18, 2022
1 parent c8b3877 commit ccc07a3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/irb/color.rb
Expand Up @@ -156,10 +156,10 @@ def colorize_code(code, complete: true, ignore_error: false, colorable: colorabl
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
Expand Down

0 comments on commit ccc07a3

Please sign in to comment.