Skip to content

Commit 036a401

Browse files
committed
Skip VS16 probe on Windows, always assume supported
Windows Terminal and conhost (Win11+) always render VS16 emoji as 2 columns. DSR probe responses don't arrive as regular console input on Windows, causing the probe to block waiting for a keypress. Only probe on Unix (Linux/macOS) where poll()+read() works reliably.
1 parent dad0fec commit 036a401

1 file changed

Lines changed: 10 additions & 21 deletions

File tree

SharpConsoleUI/Drivers/NetConsoleDriver.cs

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -822,34 +822,23 @@ private void ProbeTerminalCapabilities()
822822
{
823823
try
824824
{
825-
if (_useDirectAnsi)
825+
if (!_useDirectAnsi)
826+
{
827+
// Windows: always assume VS16 supported.
828+
// Windows Terminal and conhost (Win11+) both render VS16 emoji
829+
// as 2 columns. DSR probing via Console.In is unreliable on Windows
830+
// because escape sequence responses don't arrive as regular input.
831+
TerminalCapabilities.SetVS16Widening(true);
832+
}
833+
else
826834
{
827-
// Unix raw mode: use poll()+read() for proper kernel-level timeout.
828-
// Unlike .NET ReadAsync, poll() doesn't block when no data arrives.
835+
// Unix (Linux/macOS): probe via poll()+read() for actual terminal behavior.
829836
TerminalRawMode.FlushStdin();
830837

831838
TerminalCapabilities.Probe(
832839
write: text => TerminalRawMode.WriteStdout(text),
833840
readByte: () => TerminalRawMode.ReadByteWithTimeout(150));
834841
}
835-
else
836-
{
837-
// Windows native console: DSR responses arrive as console input events.
838-
// Use Console.In.Read with a polling fallback.
839-
TerminalCapabilities.Probe(
840-
write: Console.Out.Write,
841-
readByte: () =>
842-
{
843-
var sw = System.Diagnostics.Stopwatch.StartNew();
844-
while (sw.ElapsedMilliseconds < 150)
845-
{
846-
if (Console.KeyAvailable)
847-
return Console.In.Read();
848-
Thread.Sleep(1);
849-
}
850-
return -1;
851-
});
852-
}
853842

854843
_consoleWindowSystem?.LogService?.Log(
855844
Logging.LogLevel.Debug,

0 commit comments

Comments
 (0)