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
L. Yeung committed Mar 16, 2023
1 parent 2eb5cbf commit f18c069
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions rich/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,19 +1004,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 f18c069

Please sign in to comment.