Skip to content

Commit

Permalink
Don't colour diff headers white, only bold (GH-2691)
Browse files Browse the repository at this point in the history
So people with light themed terminals can still read 'em.
  • Loading branch information
ichard26 committed Dec 15, 2021
1 parent ab86513 commit 3083f44
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Expand Up @@ -7,6 +7,8 @@
- Improve error message for invalid regular expression (#2678)
- Fix mapping cases that contain as-expressions, like `case {"key": 1 | 2 as password}`
(#2686)
- No longer color diff headers white as it's unreadable in light themed terminals
(#2691)

## 21.12b0

Expand Down
2 changes: 1 addition & 1 deletion src/black/output.py
Expand Up @@ -81,7 +81,7 @@ def color_diff(contents: str) -> str:
lines = contents.split("\n")
for i, line in enumerate(lines):
if line.startswith("+++") or line.startswith("---"):
line = "\033[1;37m" + line + "\033[0m" # bold white, reset
line = "\033[1m" + line + "\033[0m" # bold, reset
elif line.startswith("@@"):
line = "\033[36m" + line + "\033[0m" # cyan, reset
elif line.startswith("+"):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_black.py
Expand Up @@ -200,7 +200,7 @@ def test_piping_diff_with_color(self) -> None:
)
actual = result.output
# Again, the contents are checked in a different test, so only look for colors.
self.assertIn("\033[1;37m", actual)
self.assertIn("\033[1m", actual)
self.assertIn("\033[36m", actual)
self.assertIn("\033[32m", actual)
self.assertIn("\033[31m", actual)
Expand Down Expand Up @@ -323,7 +323,7 @@ def test_expression_diff_with_color(self) -> None:
actual = result.output
# We check the contents of the diff in `test_expression_diff`. All
# we need to check here is that color codes exist in the result.
self.assertIn("\033[1;37m", actual)
self.assertIn("\033[1m", actual)
self.assertIn("\033[36m", actual)
self.assertIn("\033[32m", actual)
self.assertIn("\033[31m", actual)
Expand Down

0 comments on commit 3083f44

Please sign in to comment.