Skip to content

Commit b41cb48

Browse files
committed
fix auto detection of terminal size on Windows
1 parent 1f257b8 commit b41cb48

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- Progress track thread is now a daemon thread https://github.com/Textualize/rich/pull/3402
1818
- Fixed cached hash preservation upon clearing meta and links https://github.com/Textualize/rich/issues/2942
1919
- Fixed overriding the `background_color` of `Syntax` not including padding https://github.com/Textualize/rich/issues/3295
20+
- Fix auto detection of terminal size on Windows https://github.com/Textualize/rich/pull/2916
2021

2122
### Changed
2223

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ The following people have contributed to the development of Rich:
8585
- [Pierro](https://github.com/xpierroz)
8686
- [Bernhard Wagner](https://github.com/bwagner)
8787
- [Aaron Beaudoin](https://github.com/AaronBeaudoin)
88+
- [L. Yeung](https://github.com/lewis-yeung)

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)