You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know why. I have tried to copy the text both directly from the browser console and from a text editor. Adding an empty line at the end of the buffer doesn't work.
If I copy line by line, it works. It may be something related to the end of line/carriage return character?
The text was updated successfully, but these errors were encountered:
Sounds like a potential bug in Stdin.readLineSync() - I'm on Mac and it's working fine. What os are you using? Could you please try the following dart test file and see what we get?
import 'dart:io';
import 'dart:convert';
main() {
print("Paste something:");
String line = "";
do {
String line = readLineSync();
print("line.isEmpty=${line.isEmpty}");
} while(line.isNotEmpty);
print("DONE");
}
String readLineSync({Encoding encoding: SYSTEM_ENCODING,
bool retainNewlines: false}) {
const CR = 13;
const LF = 10;
final List line = [];
// On Windows, if lineMode is disabled, only CR is received.
bool crIsNewline = Platform.isWindows &&
(stdioType(stdin) == StdioType.TERMINAL) &&
!stdin.lineMode;
print("Platform.isWindows=${Platform.isWindows} stdioType=${stdioType(stdin)} stin.lineMode=${stdin.lineMode} crIsNewLine=$crIsNewline");
if (retainNewlines) {
int byte;
do {
byte = stdin.readByteSync();
print("Got byte $byte");
if (byte < 0) {
break;
}
line.add(byte);
} while (byte != LF && !(byte == CR && crIsNewline));
if (line.isEmpty) {
return null;
}
} else if (crIsNewline) {
// CR and LF are both line terminators, neither is retained.
while (true) {
int byte = stdin.readByteSync();
print("Got byte $byte");
if (byte < 0) {
if (line.isEmpty) return null;
break;
}
if (byte == LF || byte == CR) break;
line.add(byte);
}
} else {
// Case having to hande CR LF as a single unretained line terminator.
outer: while (true) {
int byte = stdin.readByteSync();
print("Got byte $byte");
if (byte == LF) break;
if (byte == CR) {
do {
byte = stdin.readByteSync();
print("Got byte $byte");
if (byte == LF) break outer;
line.add(CR);
} while (byte == CR);
// Fall through and handle non-CR character.
}
if (byte < 0) {
if (line.isEmpty) return null;
break;
}
line.add(byte);
}
}
return encoding.decode(line);
}
I don't know why. I have tried to copy the text both directly from the browser console and from a text editor. Adding an empty line at the end of the buffer doesn't work.
If I copy line by line, it works. It may be something related to the end of line/carriage return character?
The text was updated successfully, but these errors were encountered: