Skip to content

Commit 5a1d615

Browse files
committed
Use bold to highlight 'Failure/Error'
...instead of white, as it doesn't show up well on light color schemes.
1 parent cd8b31f commit 5a1d615

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

lib/super_diff/csi.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Source: <https://en.wikipedia.org/wiki/ANSI_escape_code>
22
module SuperDiff
33
module Csi
4+
autoload :BoldSequence, "super_diff/csi/bold_sequence"
45
autoload :Color, "super_diff/csi/color"
56
autoload :ColorSequenceBlock, "super_diff/csi/color_sequence_block"
67
autoload :ColorizedDocument, "super_diff/csi/colorized_document"

lib/super_diff/csi/bold_sequence.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module SuperDiff
2+
module Csi
3+
class BoldSequence
4+
def to_s
5+
"\e[1m"
6+
end
7+
end
8+
end
9+
end

lib/super_diff/csi/document.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ def each(&block)
1616
parts.each(&block)
1717
end
1818

19+
def bold(*args, **opts, &block)
20+
colorize(BoldSequence.new, *args, **opts, &block)
21+
end
22+
1923
def colorize(*args, **opts, &block)
2024
contents, colors = args.partition do |arg|
2125
arg.is_a?(String) || arg.is_a?(self.class)
@@ -110,10 +114,12 @@ def derive_request_from(name)
110114
match = name.to_s.match(/\A(.+)_line\Z/)
111115

112116
if match
113-
if respond_to?(match[1].to_sym)
114-
MethodRequest.new(name: match[1].to_sym, line: true)
115-
elsif Csi::Color.exists?(match[1].to_sym)
116-
ColorRequest.new(name: match[1].to_sym, line: true)
117+
color_name = match[1].to_sym
118+
119+
if respond_to?(color_name)
120+
MethodRequest.new(name: color_name, line: true)
121+
elsif Csi::Color.exists?(color_name)
122+
ColorRequest.new(name: color_name, line: true)
117123
end
118124
elsif Csi::Color.exists?(name.to_sym)
119125
ColorRequest.new(name: name.to_sym, line: false)

lib/super_diff/rspec/monkey_patches.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,7 @@ def add_shared_group_lines(lines, colorizer)
111111
def failure_slash_error_lines
112112
lines = read_failed_lines
113113

114-
failure_slash_error = ConsoleCodes.wrap(
115-
"Failure/Error: ",
116-
:white
117-
)
114+
failure_slash_error = ConsoleCodes.wrap("Failure/Error: ", :bold)
118115

119116
if lines.count == 1
120117
lines[0] = failure_slash_error + lines[0].strip

spec/support/integration/helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def build_expected_output(
114114
line "1) test passes", indent_by: 2
115115

116116
line indent_by: 5 do
117-
white "Failure/Error: "
117+
bold "Failure/Error: "
118118
plain snippet
119119
end
120120

0 commit comments

Comments
 (0)