deno
deno copied to clipboard
In raw mode on Windows, Deno.stdin.readSync drops LF character from CRLF
Version: Deno 1.39.2
To reproduce:
Save the following code to bug.ts
:
let a = new Uint8Array(2), b = new Uint8Array(2)
Deno.stdin.readSync(a)
Deno.stdin.setRaw(true)
Deno.stdin.readSync(b)
console.log(a)
console.log(b)
In a terminal, run:
deno run bug.ts
Hit Return twice.
Actual output:
Uint8Array(2) [ 13, 10 ]
Uint8Array(2) [ 13, 0 ]
The non-raw read returned <CR><LF>, the raw read returned only <CR>.
Expected output:
Uint8Array(2) [ 13, 10 ]
Uint8Array(2) [ 13, 10 ]
Both reads should return <CR><LF>.
There currently is a problem with the Fresh cli that may be related. When asked for one of the options like twind, hitting enter
to accept the default does not work. The enter does create a newline in the terminal, but the default value is not used, and the dialog seems to be stuck and never completes.
Rolling Deno back to 1.39.1 seems to fix this issue.
On mac, the above script prints:
Uint8Array(2) [ 10, 0 ]
Uint8Array(2) [ 13, 0 ]
I'm not sure this is a bug. It seems that the Enter key consistently becomes CR
in different platforms?
Can anyone test on linux?
(Note: downgrading to 1.39.1 doesn't make any change)
Yes, there has been problem with windows especially with Powershell, a related issue is found on dart
https://github.com/dart-lang/sdk/issues/54588
While i try to fix this https://github.com/dart-lang/sdk/issues/54588 on dart, @mraleph noted that this is issue from https://github.com/microsoft/terminal/issues/16223 and seems it was landed but no idea in which windows sdk version it was released. I think it can be closed @kt3k @Rummskartoffel
Can anyone on windows test the original example with the latest Windows Terminal?
I don't think it was released. It's in the 1.20 milestone and the last release was 1.19.
So you have to wait until they release it (or build Windows Terminal from sources) to test it.
The above program's output becomes in Windows terminal (1.18) Since <CR> (or Enter Key) is interpretd as 13 in windows terminal.
Uint8Array(2) [ 13, 0 ]
Uint8Array(2) [ 13, 0 ]
@Rummskartoffel
@kt3k seems it was fixed in windows terminal, so can be closed.
Edit: Tested on Windows Terminal 1.18.2
@codesculpture, my results (now on Deno 1.40.4, WT 1.18.10301.0) are still as reported. I only get your results when I run the test program multiple times in a row, so the raw flag is still set from the previous run.
Sorry for the confusion i actually tested on v1.18.2 Windows terminal @Rummskartoffel
@Rummskartoffel any update on this, have u tested on win terminal v1.18.2
@codesculpture, I'm not sure which version you mean by "v1.18.2" – that's not a version number listed at microsoft/terminal –, but I've now updated to WT 1.19.10302.0 and the behaviour is unchanged.