Repository: Textualize/rich (python)

Issue:
[BUG] inconsistent coloring of complex numbers
Not sure if I should report this as a bug or as a feature request, but there is a very minor issue when printing complex numbers: the decimal part of the imaginary number is uncolored.

try for example:

```python
>>> from rich import pretty
>>> pretty.install()
>>> 3.05 + 2.06j
(3.05+2.06j)
```

![image](https://user-images.githubusercontent.com/15832886/164705103-eca06cf1-a1c3-41ed-973c-0a02d70c8249.png)

I tried this on Linux, rich version 12.2.0. This "bug" appears both in the terminal (alacritty in my case) as well as in jupyter notebooks, which makes me believe it is platform independent.

Pull request:
[highlighter] Add complex numbers pattern to our highlighter's `number` matching
## Type of changes

- [x] Bug fix
- [ ] New feature
- [ ] Documentation / docstrings
- [ ] Tests
- [ ] Other

## Checklist

- [x] I've run the latest [black](https://github.com/psf/black) with default args on new code.
- [x] I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
- [x] I've added tests for new code.
- [x] I accept that @willmcgugan may be pedantic in the code review.

## Description

closes #2214 

The fix in action:

#### In IPython:
![Screenshot from 2022-04-25 12-24-00](https://user-images.githubusercontent.com/722388/165079687-6e497cb1-91ad-48e1-868f-f0deb7f0c5d5.png)

#### In a Jupyter notebook:
![Screenshot from 2022-04-25 12-28-04](https://user-images.githubusercontent.com/722388/165080326-d576b0be-5b2e-4a8b-b6a1-52c1fa1a71f6.png)

#### In plain Python 
![Screenshot from 2022-04-25 12-29-03](https://user-images.githubusercontent.com/722388/165080507-08913ca4-b8d4-483c-b8af-31b53a93f33c.png)



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7ce176a5..638ede8d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - Fixed markup escaping issue https://github.com/Textualize/rich/issues/2187
 - Safari - Box appearing around SVG export https://github.com/Textualize/rich/pull/2201
 - Fixed recursion error in Jupyter progress bars https://github.com/Textualize/rich/issues/2047
+- Complex numbers are now identified by the highlighter https://github.com/Textualize/rich/issues/2214
 - Fix crash on IDLE and forced is_terminal detection to False because IDLE can't do escape codes https://github.com/Textualize/rich/issues/2222
 
 ### Changed
diff --git a/rich/default_styles.py b/rich/default_styles.py
index d803eec9..1969bb78 100644
--- a/rich/default_styles.py
+++ b/rich/default_styles.py
@@ -78,6 +78,7 @@ DEFAULT_STYLES: Dict[str, Style] = {
     "repr.attrib_equal": Style(bold=True),
     "repr.attrib_value": Style(color="magenta", italic=False),
     "repr.number": Style(color="cyan", bold=True, italic=False),
+    "repr.number_complex": Style(color="cyan", bold=True, italic=False),  # same
     "repr.bool_true": Style(color="bright_green", italic=True),
     "repr.bool_false": Style(color="bright_red", italic=True),
     "repr.none": Style(color="magenta", italic=True),
diff --git a/rich/highlighter.py b/rich/highlighter.py
index 7bee4167..193261c4 100644
--- a/rich/highlighter.py
+++ b/rich/highlighter.py
@@ -94,6 +94,7 @@ class ReprHighlighter(RegexHighlighter):
             r"(?P<call>[\w.]*?)\(",
             r"\b(?P<bool_true>True)\b|\b(?P<bool_false>False)\b|\b(?P<none>None)\b",
             r"(?P<ellipsis>\.\.\.)",
+            r"(?P<number_complex>(?<!\w)(?:\-?[0-9]+\.?[0-9]*(?:e[-+]?\d+?)?)(?:[-+](?:[0-9]+\.?[0-9]*(?:e[-+]?\d+)?))?j)",
             r"(?P<number>(?<!\w)\-?[0-9]+\.?[0-9]*(e[-+]?\d+?)?\b|0x[0-9a-fA-F]*)",
             r"(?P<path>\B(/[-\w._+]+)*\/)(?P<filename>[-\w._+]*)?",
             r"(?<![\\\w])(?P<str>b?'''.*?(?<!\\)'''|b?'.*?(?<!\\)'|b?\"\"\".*?(?<!\\)\"\"\"|b?\".*?(?<!\\)\")",


Test patch:
diff --git a/tests/test_highlighter.py b/tests/test_highlighter.py
index 930b340e..0a036b72 100644
--- a/tests/test_highlighter.py
+++ b/tests/test_highlighter.py
@@ -59,6 +59,40 @@ highlight_tests = [
     (" 1.2 ", [Span(1, 4, "repr.number")]),
     (" 0xff ", [Span(1, 5, "repr.number")]),
     (" 1e10 ", [Span(1, 5, "repr.number")]),
+    (" 1j ", [Span(1, 3, "repr.number_complex")]),
+    (" 3.14j ", [Span(1, 6, "repr.number_complex")]),
+    (
+        " (3.14+2.06j) ",
+        [
+            Span(1, 2, "repr.brace"),
+            Span(12, 13, "repr.brace"),
+            Span(2, 12, "repr.number_complex"),
+        ],
+    ),
+    (
+        " (3+2j) ",
+        [
+            Span(1, 2, "repr.brace"),
+            Span(6, 7, "repr.brace"),
+            Span(2, 6, "repr.number_complex"),
+        ],
+    ),
+    (
+        " (123456.4321-1234.5678j) ",
+        [
+            Span(1, 2, "repr.brace"),
+            Span(24, 25, "repr.brace"),
+            Span(2, 24, "repr.number_complex"),
+        ],
+    ),
+    (
+        " (-123123-2.1312342342423422e+25j) ",
+        [
+            Span(1, 2, "repr.brace"),
+            Span(33, 34, "repr.brace"),
+            Span(2, 33, "repr.number_complex"),
+        ],
+    ),
     (" /foo ", [Span(1, 2, "repr.path"), Span(2, 5, "repr.filename")]),
     (" /foo/bar.html ", [Span(1, 6, "repr.path"), Span(6, 14, "repr.filename")]),
     ("01-23-45-67-89-AB", [Span(0, 17, "repr.eui48")]),  # 6x2 hyphen