Repository: Textualize/rich (python)

Issue:
[BUG] Post 13.8.1 table automatic highlighting no longer works
- [x] I've checked [docs](https://rich.readthedocs.io/en/latest/introduction.html) and [closed issues](https://github.com/Textualize/rich/issues?q=is%3Aissue+is%3Aclosed) for possible solutions.
- [x] I can't find my issue in the [FAQ](https://github.com/Textualize/rich/blob/master/FAQ.md).

**Describe the bug**

Post the 13.8.1 release, automatic highlighting of cell contents no longer seems to work.

Running the following
```python
from rich import print
from rich.table import Table

t = Table(highlight=True, show_header=False)
t.add_row("1", repr("FOO"))
print(t)
```

With release 13.7.1, one before 13.8.1, automatic highlighting works.

But with 13.8.1 or greater there's no automatic highlighting in the output.

**Platform**
<details>
<summary>Click to expand</summary>

What platform (Win/Linux/Mac) are you running on? What terminal software are you using?

```
(python -m rich.diagnose & pip freeze | grep rich) | clipcopy
```
```
╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface.                                                  │
│                                                                                  │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=265 None>                                                     │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                  │
│     color_system = None                                                          │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│           height = 38                                                            │
│    is_alt_screen = False                                                         │
│ is_dumb_terminal = False                                                         │
│   is_interactive = False                                                         │
│       is_jupyter = False                                                         │
│      is_terminal = False                                                         │
│   legacy_windows = False                                                         │
│         no_color = False                                                         │
│          options = ConsoleOptions(                                               │
│                        size=ConsoleDimensions(width=265, height=38),             │
│                        legacy_windows=False,                                     │
│                        min_width=1,                                              │
│                        max_width=265,                                            │
│                        is_terminal=False,                                        │
│                        encoding='utf-8',                                         │
│                        max_height=38,                                            │
│                        justify=None,                                             │
│                        overflow=None,                                            │
│                        no_wrap=False,                                            │
│                        highlight=None,                                           │
│                        markup=None,                                              │
│                        height=None                                               │
│                    )                                                             │
│            quiet = False                                                         │
│           record = False                                                         │
│         safe_box = True                                                          │
│             size = ConsoleDimensions(width=265, height=38)                       │
│        soft_wrap = False                                                         │
│           stderr = False                                                         │
│            style = None                                                          │
│         tab_size = 8                                                             │
│            width = 265                                                           │
╰──────────────────────────────────────────────────────────────────────────────────╯
╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
│ Windows features available.                           │
│                                                       │
│ ╭───────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ ╰───────────────────────────────────────────────────╯ │
│                                                       │
│ truecolor = False                                     │
│        vt = False                                     │
╰───────────────────────────────────────────────────────╯
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────── Environment Variables ───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ {'TERM': 'alacritty', 'COLORTERM': 'truecolor', 'CLICOLOR': None, 'NO_COLOR': None, 'TERM_PROGRAM': 'tmux', 'COLUMNS': None, 'LINES': None, 'JUPYTER_COLUMNS': None, 'JUPYTER_LINES': None, 'JPY_PARENT_PID': None, 'VSCODE_VERBOSE_LOGGING': None} │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
platform="Darwin"
rich==13.7.1
```

</details>


Pull request description:
fix(table): highlight columns added by add_row
## 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

Fixes #3517. The default value for the `Column.highlight` is False, so where necessary columns are added by the `add_row` method this should default to the `Table.highlight` value.

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a0bae8d5..1915a9d3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
+## Unreleased
+
+### Fixed
+
+- Fixed `Table` columns not highlighting when added by `add_row` https://github.com/Textualize/rich/issues/3517
+
 ## [13.9.1] - 2024-10-01
 
 ### Fixed
diff --git a/rich/table.py b/rich/table.py
index 10af2e6f..7b1fa9e4 100644
--- a/rich/table.py
+++ b/rich/table.py
@@ -451,7 +451,7 @@ class Table(JupyterMixin):
             ]
         for index, renderable in enumerate(cell_renderables):
             if index == len(columns):
-                column = Column(_index=index)
+                column = Column(_index=index, highlight=self.highlight)
                 for _ in self.rows:
                     add_cell(column, Text(""))
                 self.columns.append(column)


Test patch:
diff --git a/tests/test_table.py b/tests/test_table.py
index 79033f21..8767283c 100644
--- a/tests/test_table.py
+++ b/tests/test_table.py
@@ -363,6 +363,25 @@ def test_placement_table_box_elements(show_header, show_footer, expected):
     assert output == expected
 
 
+def test_columns_highlight_added_by_add_row() -> None:
+    """Regression test for https://github.com/Textualize/rich/issues/3517"""
+    table = Table(show_header=False, highlight=True)
+    table.add_row("1", repr("FOO"))
+
+    assert table.columns[0].highlight == table.highlight
+    assert table.columns[1].highlight == table.highlight
+
+    console = Console(record=True)
+    console.print(table)
+    output = console.export_text(styles=True)
+    print(repr(output))
+
+    expected = (
+        "┌───┬───────┐\n│ \x1b[1;36m1\x1b[0m │ \x1b[32m'FOO'\x1b[0m │\n└───┴───────┘\n"
+    )
+    assert output == expected
+
+
 if __name__ == "__main__":
     render = render_tables()
     print(render)