Merge branch 'fix-icat_typeerror_on_print_window_size' of https://github.com/nertro/kitty

This commit is contained in:
Kovid Goyal 2022-03-12 08:08:32 +05:30
commit f6fb36c58a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 2 deletions

View File

@ -515,7 +515,12 @@ def main(args: List[str] = sys.argv) -> None:
if cli_opts.print_window_size:
screen_size_function.cache_clear()
with open(os.ctermid()) as tty:
ss = screen_size_function(tty)()
try:
fd = tty.fileno()
except AttributeError:
# use default value for fd if ctermid is not available
fd = None
ss = screen_size_function(fd)()
print(f'{ss.width}x{ss.height}', end='')
raise SystemExit(0)

View File

@ -178,7 +178,7 @@ class ScreenSizeGetter:
return cast(ScreenSize, self.ans)
@lru_cache(maxsize=64)
@lru_cache(maxsize=64, typed=True)
def screen_size_function(fd: Optional[int] = None) -> ScreenSizeGetter:
return ScreenSizeGetter(fd)