Skip to content

Conversation

@aam
Copy link
Member

@aam aam commented May 19, 2017

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'.


Future<Null> processTerminalInput(String command) async {
// When terminal doesn't support line mode, '\n' can sneak into the input.
command = command.replaceAll('\n', '');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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...

Copy link
Contributor

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?

Copy link
Member Author

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'.

@Hixie
Copy link
Contributor

Hixie commented May 21, 2017

This needs tests.

@Hixie
Copy link
Contributor

Hixie commented May 21, 2017

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.

@aam
Copy link
Member Author

aam commented May 21, 2017

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.

@Hixie
Copy link
Contributor

Hixie commented May 21, 2017

I am able to enter blank lines when running flutter run from the shell terminal today. I do it all the time. :-)

@aam
Copy link
Member Author

aam commented May 21, 2017

Ah, '-v' option (as in flutter run -v) somehow makes a difference in regards to how newlines are displayed.
Yes, without '-v' option newlines are entered, and this PR doesn't affect existing behavior.

@aam
Copy link
Member Author

aam commented May 21, 2017

This needs tests.

Sure, added few tests.

Future<int> run({Completer<DebugConnectionInfo> connectionInfoCompleter,
Completer<dynamic> appStartedCompleter,
String route,
bool shouldBuild: true}) => null;
Copy link
Contributor

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;

Copy link
Member Author

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}) {
Copy link
Contributor

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

Copy link
Member Author

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)
Copy link
Contributor

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

Copy link
Member Author

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())]);
Copy link
Contributor

@Hixie Hixie May 21, 2017

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 =.

Copy link
Member Author

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,
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Hixie
Copy link
Contributor

Hixie commented May 21, 2017

LGTM

@aam
Copy link
Member Author

aam commented May 21, 2017

Not sure what the next steps are, as I don't think I have merge permissions. :)

@Hixie Hixie merged commit 5b1e972 into flutter:master May 21, 2017
@Hixie
Copy link
Contributor

Hixie commented May 21, 2017

I landed it for you. :-)

@aam
Copy link
Member Author

aam commented May 21, 2017

Thanks!

@aam aam deleted the remove-newline-from-terminal-command branch June 30, 2017 14:24
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants