1
0
mirror of https://github.com/fiatjaf/nak.git synced 2025-08-10 21:20:47 -04:00

fix term.GetSize() when piping.

This commit is contained in:
fiatjaf
2025-04-03 22:08:11 -03:00
parent 6f48c29d0f
commit 55fd631787

@@ -305,7 +305,7 @@ func supportsDynamicMultilineMagic() bool {
return false return false
} }
width, _, err := term.GetSize(0) width, _, err := term.GetSize(int(os.Stderr.Fd()))
if err != nil { if err != nil {
return false return false
} }
@@ -373,7 +373,7 @@ func unwrapAll(err error) error {
} }
func clampMessage(msg string, prefixAlreadyPrinted int) string { func clampMessage(msg string, prefixAlreadyPrinted int) string {
termSize, _, _ := term.GetSize(0) termSize, _, _ := term.GetSize(int(os.Stderr.Fd()))
if len(msg) > termSize-prefixAlreadyPrinted { if len(msg) > termSize-prefixAlreadyPrinted {
msg = msg[0:termSize-prefixAlreadyPrinted-1] + "…" msg = msg[0:termSize-prefixAlreadyPrinted-1] + "…"
} }