Skip to content

Commit 507f549

Browse files
committed
fix row_style applying to header
1 parent cb58cfd commit 507f549

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.8.10] - 2020-04-12
9+
10+
### Fixed
11+
12+
- Fix row_styles applying to header
13+
814
## [0.8.9] - 2020-04-12
915

1016
### Changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rich"
33
homepage = "https://github.com/willmcgugan/rich"
44
documentation = "https://rich.readthedocs.io/en/latest/"
5-
version = "0.8.9"
5+
version = "0.8.10"
66
description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
77
authors = ["Will McGugan <[email protected]>"]
88
license = "MIT"

rich/table.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,12 @@ def _render(
453453
for index, (first, last, row) in enumerate(loop_first_last(rows)):
454454
max_height = 1
455455
cells: List[List[List[Segment]]] = []
456-
row_style = get_style(get_row_style(index))
456+
if show_header and first:
457+
row_style = Style()
458+
else:
459+
row_style = get_style(
460+
get_row_style(index - 1 if show_header else index)
461+
)
457462
for width, cell, column in zip(widths, row, columns):
458463
render_options = options.update(width=width, justify=column.justify)
459464
cell_style = table_style + row_style + get_style(cell.style)
@@ -517,8 +522,8 @@ def _render(
517522
from .console import Console
518523

519524
c = Console()
520-
table = Table(row_styles=["grey44", "white"], expand=True)
521-
table.add_column(no_wrap=True)
525+
table = Table(row_styles=["red", "green"], expand=True)
526+
table.add_column("foo", no_wrap=True)
522527
table.add_column()
523528
table.add_row(
524529
"Magnet",

0 commit comments

Comments
 (0)