diff --git a/lib/irb.rb b/lib/irb.rb index f48a0a2d4d..6887d5596e 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -824,17 +824,20 @@ module IRB diff_size = output_width - Reline::Unicode.calculate_width(first_line, true) if diff_size.positive? and output_width > winwidth lines, _ = Reline::Unicode.split_by_width(first_line, winwidth - diff_size - 3) - str = "%s...\e[0m" % lines.first + str = "%s..." % lines.first + str += "\e[0m" if @context.use_colorize multiline_p = false else - str = str.gsub(/(\A.*?\n).*/m, "\\1...\e[0m") + str = str.gsub(/(\A.*?\n).*/m, "\\1...") + str += "\e[0m" if @context.use_colorize end else output_width = Reline::Unicode.calculate_width(@context.return_format % str, true) diff_size = output_width - Reline::Unicode.calculate_width(str, true) if diff_size.positive? and output_width > winwidth lines, _ = Reline::Unicode.split_by_width(str, winwidth - diff_size - 3) - str = "%s...\e[0m" % lines.first + str = "%s..." % lines.first + str += "\e[0m" if @context.use_colorize end end end diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index d908195e6a..42f82fc37e 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -259,6 +259,7 @@ module TestIRB end def test_omit_on_assignment + IRB.conf[:USE_COLORIZE] = false input = TestInputMethod.new([ "a = [1] * 100\n", "a\n", @@ -322,6 +323,7 @@ module TestIRB end def test_omit_multiline_on_assignment + IRB.conf[:USE_COLORIZE] = false input = TestInputMethod.new([ "class A; def inspect; ([?* * 1000] * 3).join(%{\\n}); end; end; a = A.new\n", "a\n" @@ -347,7 +349,7 @@ module TestIRB irb.eval_input end assert_empty err - assert_equal("=> #{value_first_line[0..(input.winsize.last - 9)]}...\e[0m\n=> \n#{value}\n", out) + assert_equal("=> #{value_first_line[0..(input.winsize.last - 9)]}...\n=> \n#{value}\n", out) irb.context.evaluate('A.remove_method(:inspect)', 0) input.reset @@ -395,6 +397,7 @@ module TestIRB # Default IRB.conf[:ECHO] = nil IRB.conf[:ECHO_ON_ASSIGNMENT] = nil + IRB.conf[:USE_COLORIZE] = false input = TestInputMethod.new() irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input) @@ -422,6 +425,7 @@ module TestIRB def main.inspect "abc\ndef" end + IRB.conf[:USE_COLORIZE] = false input = TestInputMethod.new([ "self" ])