Don't colour diff headers white, only bold (GH-2691)

So people with light themed terminals can still read 'em.
This commit is contained in:
Richard Si 2021-12-14 19:32:14 -05:00 committed by GitHub
parent ab86513710
commit 3083f4470b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View File

@ -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

View File

@ -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("+"):

View File

@ -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)
@ -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)