Skip to content

Commit e807ba5

Browse files
committed
fix auto detection of terminal size on Windows
1 parent 86418df commit e807ba5

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
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 auto detection of terminal size on Windows https://github.com/Textualize/rich/pull/2916
13+
814
## [13.3.4] - 2023-04-12
915

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

55-
### Added
61+
### Added
5662

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

CONTRIBUTORS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ The following people have contributed to the development of Rich:
6767
- [Adrian Zuber](https://github.com/xadrianzetx)
6868
- [Ke Sun](https://github.com/ksun212)
6969
- [Qiming Xu](https://github.com/xqm32)
70+
- [L. Yeung](https://github.com/lewis-yeung)
7071
- [James Addison](https://github.com/jayaddison)
71-
- [Pierro](https://github.com/xpierroz)
72+
- [Pierro](https://github.com/xpierroz)

rich/console.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,19 +1005,13 @@ def size(self) -> ConsoleDimensions:
10051005
width: Optional[int] = None
10061006
height: Optional[int] = None
10071007

1008-
if WINDOWS: # pragma: no cover
1008+
for file_descriptor in _STD_STREAMS_OUTPUT if WINDOWS else _STD_STREAMS:
10091009
try:
1010-
width, height = os.get_terminal_size()
1010+
width, height = os.get_terminal_size(file_descriptor)
10111011
except (AttributeError, ValueError, OSError): # Probably not a terminal
10121012
pass
1013-
else:
1014-
for file_descriptor in _STD_STREAMS:
1015-
try:
1016-
width, height = os.get_terminal_size(file_descriptor)
1017-
except (AttributeError, ValueError, OSError):
1018-
pass
1019-
else:
1020-
break
1013+
else:
1014+
break
10211015

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

0 commit comments

Comments
 (0)