Skip to content

Commit

Permalink
fix auto detection of terminal size on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis-yeung committed Apr 16, 2023
1 parent 86418df commit e807ba5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
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 auto detection of terminal size on Windows https://github.com/Textualize/rich/pull/2916

## [13.3.4] - 2023-04-12

### Fixed
Expand Down Expand Up @@ -52,7 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed failing tests due to Pygments dependency https://github.com/Textualize/rich/issues/2757
- Relaxed ipywidgets https://github.com/Textualize/rich/issues/2767

### Added
### Added

- Added `encoding` parameter in `Theme.read`

Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ The following people have contributed to the development of Rich:
- [Adrian Zuber](https://github.com/xadrianzetx)
- [Ke Sun](https://github.com/ksun212)
- [Qiming Xu](https://github.com/xqm32)
- [L. Yeung](https://github.com/lewis-yeung)
- [James Addison](https://github.com/jayaddison)
- [Pierro](https://github.com/xpierroz)
- [Pierro](https://github.com/xpierroz)
14 changes: 4 additions & 10 deletions rich/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,19 +1005,13 @@ def size(self) -> ConsoleDimensions:
width: Optional[int] = None
height: Optional[int] = None

if WINDOWS: # pragma: no cover
for file_descriptor in _STD_STREAMS_OUTPUT if WINDOWS else _STD_STREAMS:
try:
width, height = os.get_terminal_size()
width, height = os.get_terminal_size(file_descriptor)
except (AttributeError, ValueError, OSError): # Probably not a terminal
pass
else:
for file_descriptor in _STD_STREAMS:
try:
width, height = os.get_terminal_size(file_descriptor)
except (AttributeError, ValueError, OSError):
pass
else:
break
else:
break

columns = self._environ.get("COLUMNS")
if columns is not None and columns.isdigit():
Expand Down

0 comments on commit e807ba5

Please sign in to comment.