Skip to content

Commit 5d3f600

Browse files
authored
Merge pull request #2458 from Textualize/no-color-legacy-windows-fix
Handle 'no_color' Console on legacy Windows platforms
2 parents 3304073 + 42afd3a commit 5d3f600

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
os: [windows-latest, ubuntu-latest, macos-latest]
11-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11.0-beta.4"]
11+
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
1212
defaults:
1313
run:
1414
shell: bash
@@ -36,15 +36,9 @@ jobs:
3636
source $VENV
3737
make typecheck
3838
- name: Test with pytest (with coverage)
39-
if: matrix.python-version != '3.11.0-beta.4'
4039
run: |
4140
source $VENV
4241
pytest tests -v --cov=./rich --cov-report=xml:./coverage.xml --cov-report term-missing
43-
- name: Test with pytest (no coverage)
44-
if: matrix.python-version == '3.11.0-beta.4'
45-
run: |
46-
source $VENV
47-
pytest tests -v
4842
- name: Upload code coverage
4943
uses: codecov/codecov-action@v2
5044
with:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
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+
## [Unreleased]
9+
10+
### Fixed
11+
12+
- Fix NO_COLOR support on legacy Windows https://github.com/Textualize/rich/pull/2458
13+
814
## [12.5.2] - 2022-07-18
915

1016
### Added

rich/console.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,9 +1996,11 @@ def _check_buffer(self) -> None:
19961996
from rich._win32_console import LegacyWindowsTerm
19971997
from rich._windows_renderer import legacy_windows_render
19981998

1999-
legacy_windows_render(
2000-
self._buffer[:], LegacyWindowsTerm(self.file)
2001-
)
1999+
buffer = self._buffer[:]
2000+
if self.no_color and self._color_system:
2001+
buffer = list(Segment.remove_color(buffer))
2002+
2003+
legacy_windows_render(buffer, LegacyWindowsTerm(self.file))
20022004
else:
20032005
# Either a non-std stream on legacy Windows, or modern Windows.
20042006
text = self._render_buffer(self._buffer[:])

0 commit comments

Comments
 (0)