diff --git a/setup.py b/setup.py index 96beb7f91..01949cd28 100755 --- a/setup.py +++ b/setup.py @@ -897,6 +897,8 @@ def update_go_generated_files(args: Options, kitty_exe: str) -> None: def build_kitty_tool(args: Options, launcher_dir: str, for_freeze: bool = False) -> None: + sys.stdout.flush() + sys.stderr.flush() go = shutil.which('go') if not go: raise SystemExit('The go tool was not found on this system. Install Go') diff --git a/tools/cli/infrastructure.go b/tools/cli/infrastructure.go index 20a490d5c..c4f224dc6 100644 --- a/tools/cli/infrastructure.go +++ b/tools/cli/infrastructure.go @@ -14,7 +14,7 @@ import ( "github.com/mattn/go-runewidth" "github.com/spf13/cobra" "github.com/spf13/pflag" - "golang.org/x/term" + "golang.org/x/sys/unix" "kitty" "kitty/tools/utils" @@ -328,9 +328,16 @@ func full_command_name(cmd *cobra.Command) string { func show_usage(cmd *cobra.Command, use_pager bool) error { screen_width := 80 if stdout_is_terminal { - screen_width, _, tty_size_err := term.GetSize(int(os.Stdout.Fd())) - if tty_size_err != nil || screen_width > 80 { - screen_width = 80 + var sz *unix.Winsize + var tty_size_err error + for { + sz, tty_size_err = unix.IoctlGetWinsize(int(os.Stdout.Fd()), unix.TIOCGWINSZ) + if tty_size_err != unix.EINTR { + break + } + } + if tty_size_err == nil && sz.Col < 80 { + screen_width = int(sz.Col) } } var output strings.Builder