Skip to content

Commit

Permalink
Merge pull request #2458 from Textualize/no-color-legacy-windows-fix
Browse files Browse the repository at this point in the history
Handle 'no_color' Console on legacy Windows platforms
  • Loading branch information
willmcgugan committed Aug 9, 2022
2 parents 3304073 + 42afd3a commit 5d3f600
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
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

0 comments on commit 5d3f600

Please sign in to comment.