Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Added

- Added `compact` parameter to `MaskedInput` https://github.com/Textualize/textual/pull/5952

### Fixed

- Fixed `query_one` and `query_exactly_one` not raising documented `WrongType` exception.
- Fixed logging to a file on Windows https://github.com/Textualize/textual/issues/5941
- Fixed eight bit colors crashing when applying dim style https://github.com/Textualize/textual/pull/5957

### Changed

Expand All @@ -25,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Added `Markdown.append` https://github.com/Textualize/textual/pull/5950
- Added `Widget.release_anchor` https://github.com/Textualize/textual/pull/5950
- Added `compact` parameter to `MaskedInput` https://github.com/Textualize/textual/pull/5952

## [3.7.1] - 2025-07-09

Expand Down
4 changes: 2 additions & 2 deletions src/textual/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ def truecolor_style(self, style: Style, background: RichColor) -> Style:
"""
terminal_theme = self._terminal_theme
color = style.color
if color is not None and color.is_system_defined:
if color is not None and color.triplet is None:
color = RichColor.from_rgb(
*color.get_truecolor(terminal_theme, foreground=True)
)
bgcolor = style.bgcolor
if bgcolor is not None and bgcolor.is_system_defined:
if bgcolor is not None and bgcolor.triplet is None:
bgcolor = RichColor.from_rgb(
*bgcolor.get_truecolor(terminal_theme, foreground=False)
)
Expand Down
29 changes: 29 additions & 0 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from rich.color import Color as RichColor
from rich.color import ColorType
from rich.segment import Segment
from rich.style import Style
from rich.terminal_theme import MONOKAI

from textual.color import Color
from textual.filter import ANSIToTruecolor


def test_ansi_to_truecolor_8_bit_dim():
"""Test that converting an 8-bit color with dim doesn't crash.

Regression test for https://github.com/Textualize/textual/issues/5946

"""
# Given
ansi_filter = ANSIToTruecolor(MONOKAI)
test_color = RichColor("color(253)", ColorType.EIGHT_BIT, number=253)
test_style = Style(color=test_color, dim=True)
segments = [Segment("This should not crash", style=test_style)]
background_color = Color(0, 0, 0)

# When
# This line will crash if the bug is present
new_segments = ansi_filter.apply(segments, background_color)

# Then
assert new_segments is not None
Loading