Skip to content

Preserve terminal-default foregrounds during brightness adjustment - #2138

Open
FanWu-ai wants to merge 1 commit into
prompt-toolkit:mainfrom
FanWu-ai:fix-default-foreground-brightness-20261012
Open

FanWu-ai wants to merge 1 commit into
prompt-toolkit:mainfrom
FanWu-ai:fix-default-foreground-brightness-20261012

Conversation

@FanWu-ai

Copy link
Copy Markdown

A valid fg:default style crashes AdjustBrightnessStyleTransformation because its terminal-default sentinel is passed to RGB parsing. This can prevent printing or rendering whenever brightness adjustment is enabled.

Preserve default foregrounds alongside the existing ansidefault handling. Ten new cases cover both brightness directions, explicit style parsing, default backgrounds, and None/empty/ANSI-default controls. Four reproduce the original crash.

Validation on Linux/Python 3.12:

  • Pristine complete suite: 156 passed; final complete suite: 166 passed, no skips.
  • Ruff, format, typos, strict Mypy for all three configured platforms, and all 12 pinned hooks pass.
  • Builds, strict package metadata checks, and artifact byte comparisons pass.
  • Real VT100 printing preserves default foreground and bold; 852 additional independent cases pass.

Other Python/native OS combinations and hosted CI are not claimed. Prepared and tested with AI assistance (OpenAI Codex); no human review is claimed.

Keep the default sentinel out of RGB parsing and cover parsed styles and both brightness directions.

AI assistance: OpenAI Codex.
@FanWu-ai
FanWu-ai marked this pull request as ready for review October 11, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant