mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[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
2 changed files with 11 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
])
|
||||
|
|
Loading…
Reference in a new issue