diff options
author | David Lord <davidism@gmail.com> | 2021-09-26 07:42:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-26 07:42:24 -0700 |
commit | 6bb518f82c5c119b4e4e1ebae3b2f191632060cf (patch) | |
tree | 958a2519d47b7f414f86917cf0eacdc24ae37fc2 | |
parent | 01e4dac0b1f855a54eb923380d6af64171c66f22 (diff) | |
parent | cf3b138a87e4a0c4a2d5907dc625733f533e1cfe (diff) | |
download | click-6bb518f82c5c119b4e4e1ebae3b2f191632060cf.tar.gz |
Merge pull request #2058 from jap/improve-copy-paste
fix overline and italic styles
-rw-r--r-- | CHANGES.rst | 2 | ||||
-rw-r--r-- | src/click/termui.py | 4 | ||||
-rw-r--r-- | tests/test_utils.py | 12 |
3 files changed, 14 insertions, 4 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 77783c7..e4e69b1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -18,6 +18,8 @@ Unreleased avoiding some unexpected warning output. :issue:`1738, 2017` - Fix type annotation for ``type`` argument in ``prompt`` function. :issue:`2062` +- Fix overline and italic styles, which were incorrectly added when + adding underline. :pr:`2058` Version 8.0.1 diff --git a/src/click/termui.py b/src/click/termui.py index 042fc4b..a023f42 100644 --- a/src/click/termui.py +++ b/src/click/termui.py @@ -596,9 +596,9 @@ def style( if underline is not None: bits.append(f"\033[{4 if underline else 24}m") if overline is not None: - bits.append(f"\033[{53 if underline else 55}m") + bits.append(f"\033[{53 if overline else 55}m") if italic is not None: - bits.append(f"\033[{5 if underline else 23}m") + bits.append(f"\033[{3 if italic else 23}m") if blink is not None: bits.append(f"\033[{5 if blink else 25}m") if reverse is not None: diff --git a/tests/test_utils.py b/tests/test_utils.py index 23b3709..d21b246 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -67,11 +67,19 @@ def test_echo_custom_file(): ({"bold": True}, "\x1b[1mx y\x1b[0m"), ({"dim": True}, "\x1b[2mx y\x1b[0m"), ({"underline": True}, "\x1b[4mx y\x1b[0m"), - ({"overline": True}, "\x1b[55mx y\x1b[0m"), - ({"italic": True}, "\x1b[23mx y\x1b[0m"), + ({"overline": True}, "\x1b[53mx y\x1b[0m"), + ({"italic": True}, "\x1b[3mx y\x1b[0m"), ({"blink": True}, "\x1b[5mx y\x1b[0m"), ({"reverse": True}, "\x1b[7mx y\x1b[0m"), ({"strikethrough": True}, "\x1b[9mx y\x1b[0m"), + ({"bold": False}, "\x1b[22mx y\x1b[0m"), + ({"dim": False}, "\x1b[22mx y\x1b[0m"), + ({"underline": False}, "\x1b[24mx y\x1b[0m"), + ({"overline": False}, "\x1b[55mx y\x1b[0m"), + ({"italic": False}, "\x1b[23mx y\x1b[0m"), + ({"blink": False}, "\x1b[25mx y\x1b[0m"), + ({"reverse": False}, "\x1b[27mx y\x1b[0m"), + ({"strikethrough": False}, "\x1b[29mx y\x1b[0m"), ({"fg": "black", "reset": False}, "\x1b[30mx y"), ], ) |