Skip to content

Commit 68ead31

Browse files
authored
Merge pull request #3413 from lewis-yeung/dev
Fix auto detection of terminal size on Windows
2 parents ee46ccd + 255c3ed commit 68ead31

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
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
### Fixed
1717

1818
- Fixed issue with Segment._split_cells https://github.com/Textualize/rich/pull/3506
19+
- Fix auto detection of terminal size on Windows https://github.com/Textualize/rich/pull/2916
1920

2021
### Added
2122

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,6 @@ The following people have contributed to the development of Rich:
8787
- [Pierro](https://github.com/xpierroz)
8888
- [Bernhard Wagner](https://github.com/bwagner)
8989
- [Aaron Beaudoin](https://github.com/AaronBeaudoin)
90+
- [L. Yeung](https://github.com/lewis-yeung)
9091
- [chthollyphile](https://github.com/chthollyphile)
9192
- [Jonathan Helmus](https://github.com/jjhelmus)

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)