From e2845e1b095b280cc96a765aec4e5171195c1a6f Mon Sep 17 00:00:00 2001 From: Ryan McConnell Date: Wed, 17 Dec 2025 22:52:39 -0500 Subject: [PATCH] flush `stdout` when prompting for password (#25348) Saw this misbehave on Linux. It was fine in Windows when I checked, but I figured it can't hurt. --- lib/pure/terminal.nim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pure/terminal.nim b/lib/pure/terminal.nim index 895f658e4d..fb6b4748e2 100644 --- a/lib/pure/terminal.nim +++ b/lib/pure/terminal.nim @@ -909,6 +909,7 @@ when defined(windows): ## `true` otherwise. password.setLen(0) stdout.write(prompt) + stdout.flushFile() let hi = createFileA("CONIN$", GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, 0, 0) var mode = DWORD 0 @@ -936,6 +937,7 @@ else: cur.c_lflag = cur.c_lflag and not Cflag(ECHO) discard fd.tcSetAttr(TCSADRAIN, cur.addr) stdout.write prompt + stdout.flushFile() result = stdin.readLine(password) stdout.write "\n" discard fd.tcSetAttr(TCSADRAIN, old.addr)