-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Filter out '\n' from terminal input. #10220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter out '\n' from terminal input. #10220
Conversation
|
|
||
| Future<Null> processTerminalInput(String command) async { | ||
| // When terminal doesn't support line mode, '\n' can sneak into the input. | ||
| command = command.replaceAll('\n', ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, of course, thanks! Somehow when I was looking for something like trim, I missed it. Not sure why...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trim() and replaceAll() have different semantics. Which are you expecting? Do you just want to remove a trailing LF?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intent is to remove leading and trailing '\n'.
|
This needs tests. |
|
Will this prevent users from hitting enter a few times to enter newlines? It's often useful to be able to enter a bunch of blank lines when you've got lots of debugging output. |
I don't think this changes behavior around entering newlines - you are still able to enter blank lines in IJ Console view, and you are still(same as before this change) not able to enter blank lines when running 'flutter run' from shell terminal. |
|
I am able to enter blank lines when running |
|
Ah, '-v' option (as in |
Sure, added few tests. |
| Future<int> run({Completer<DebugConnectionInfo> connectionInfoCompleter, | ||
| Completer<dynamic> appStartedCompleter, | ||
| String route, | ||
| bool shouldBuild: true}) => null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future<int> run({
Completer<DebugConnectionInfo> connectionInfoCompleter,
Completer<dynamic> appStartedCompleter,
String route,
bool shouldBuild: true,
}) => null;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| } | ||
|
|
||
| @override | ||
| void printHelp({bool details}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: spaces around named arguments please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| bool hasHelpBeenPrinted = false; | ||
| String receivedCommand; | ||
|
|
||
| TestRunner(List<FlutterDevice> devices) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: constructor should be first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
|
||
| setUp(() { | ||
| testRunner = | ||
| new TestRunner(<FlutterDevice>[new FlutterDevice(new MockDevice())]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: either indent the second line, or, preferred, put the line breaks after the first ( and before the last ) instead of after the =.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| testUsingContext('single help character', () async { | ||
| expect(testRunner.hasHelpBeenPrinted, isFalse); | ||
| await testRunner.processTerminalInput('h'); | ||
| expect(testRunner.hasHelpBeenPrinted, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: no need to have a line break in these expect calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
Not sure what the next steps are, as I don't think I have merge permissions. :) |
|
I landed it for you. :-) |
|
Thanks! |
Terminal input could have newline characters when terminal doesn't support line mode.
This is happening, for example, when running/debugging flutter_tools from IntelliJ where input from Console view comes with those extra '\n'.