[ruby/irb] Check colorize option correctly to clear char attr and don't use it for tests
https://github.com/ruby/irb/commit/de561cafeb
This commit is contained in:
parent
093aaeffbc
commit
1855f901c8
@ -824,17 +824,20 @@ module IRB
|
|||||||
diff_size = output_width - Reline::Unicode.calculate_width(first_line, true)
|
diff_size = output_width - Reline::Unicode.calculate_width(first_line, true)
|
||||||
if diff_size.positive? and output_width > winwidth
|
if diff_size.positive? and output_width > winwidth
|
||||||
lines, _ = Reline::Unicode.split_by_width(first_line, winwidth - diff_size - 3)
|
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
|
multiline_p = false
|
||||||
else
|
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
|
end
|
||||||
else
|
else
|
||||||
output_width = Reline::Unicode.calculate_width(@context.return_format % str, true)
|
output_width = Reline::Unicode.calculate_width(@context.return_format % str, true)
|
||||||
diff_size = output_width - Reline::Unicode.calculate_width(str, true)
|
diff_size = output_width - Reline::Unicode.calculate_width(str, true)
|
||||||
if diff_size.positive? and output_width > winwidth
|
if diff_size.positive? and output_width > winwidth
|
||||||
lines, _ = Reline::Unicode.split_by_width(str, winwidth - diff_size - 3)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
@ -259,6 +259,7 @@ module TestIRB
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_omit_on_assignment
|
def test_omit_on_assignment
|
||||||
|
IRB.conf[:USE_COLORIZE] = false
|
||||||
input = TestInputMethod.new([
|
input = TestInputMethod.new([
|
||||||
"a = [1] * 100\n",
|
"a = [1] * 100\n",
|
||||||
"a\n",
|
"a\n",
|
||||||
@ -322,6 +323,7 @@ module TestIRB
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_omit_multiline_on_assignment
|
def test_omit_multiline_on_assignment
|
||||||
|
IRB.conf[:USE_COLORIZE] = false
|
||||||
input = TestInputMethod.new([
|
input = TestInputMethod.new([
|
||||||
"class A; def inspect; ([?* * 1000] * 3).join(%{\\n}); end; end; a = A.new\n",
|
"class A; def inspect; ([?* * 1000] * 3).join(%{\\n}); end; end; a = A.new\n",
|
||||||
"a\n"
|
"a\n"
|
||||||
@ -347,7 +349,7 @@ module TestIRB
|
|||||||
irb.eval_input
|
irb.eval_input
|
||||||
end
|
end
|
||||||
assert_empty err
|
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)
|
irb.context.evaluate('A.remove_method(:inspect)', 0)
|
||||||
|
|
||||||
input.reset
|
input.reset
|
||||||
@ -395,6 +397,7 @@ module TestIRB
|
|||||||
# Default
|
# Default
|
||||||
IRB.conf[:ECHO] = nil
|
IRB.conf[:ECHO] = nil
|
||||||
IRB.conf[:ECHO_ON_ASSIGNMENT] = nil
|
IRB.conf[:ECHO_ON_ASSIGNMENT] = nil
|
||||||
|
IRB.conf[:USE_COLORIZE] = false
|
||||||
input = TestInputMethod.new()
|
input = TestInputMethod.new()
|
||||||
irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
|
irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
|
||||||
|
|
||||||
@ -422,6 +425,7 @@ module TestIRB
|
|||||||
def main.inspect
|
def main.inspect
|
||||||
"abc\ndef"
|
"abc\ndef"
|
||||||
end
|
end
|
||||||
|
IRB.conf[:USE_COLORIZE] = false
|
||||||
input = TestInputMethod.new([
|
input = TestInputMethod.new([
|
||||||
"self"
|
"self"
|
||||||
])
|
])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user