Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle 'no_color' Console on legacy Windows platforms #2458

Merged
merged 6 commits into from Aug 9, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 1 addition & 7 deletions .github/workflows/pythonpackage.yml
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11.0-beta.4"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
defaults:
run:
shell: bash
Expand Down Expand Up @@ -36,15 +36,9 @@ jobs:
source $VENV
make typecheck
- name: Test with pytest (with coverage)
if: matrix.python-version != '3.11.0-beta.4'
run: |
source $VENV
pytest tests -v --cov=./rich --cov-report=xml:./coverage.xml --cov-report term-missing
- name: Test with pytest (no coverage)
if: matrix.python-version == '3.11.0-beta.4'
run: |
source $VENV
pytest tests -v
- name: Upload code coverage
uses: codecov/codecov-action@v2
with:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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

- Fix NO_COLOR support on legacy Windows https://github.com/Textualize/rich/pull/2458

## [12.5.2] - 2022-07-18

### Added
Expand Down
8 changes: 5 additions & 3 deletions rich/console.py
Expand Up @@ -1996,9 +1996,11 @@ def _check_buffer(self) -> None:
from rich._win32_console import LegacyWindowsTerm
from rich._windows_renderer import legacy_windows_render

legacy_windows_render(
self._buffer[:], LegacyWindowsTerm(self.file)
)
buffer = self._buffer[:]
if self.no_color and self._color_system:
buffer = list(Segment.remove_color(buffer))

legacy_windows_render(buffer, LegacyWindowsTerm(self.file))
else:
# Either a non-std stream on legacy Windows, or modern Windows.
text = self._render_buffer(self._buffer[:])
Expand Down