-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
fix: terminal, handle newline #12342
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
Conversation
f86e059
to
28d4db4
Compare
28d4db4
to
969bfab
Compare
969bfab
to
8837590
Compare
Signed-off-by: fufesou <linlong1266@gmail.com>
8837590
to
0eebcc5
Compare
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.
Pull Request Overview
This PR fixes a terminal input handling issue where Android keyboards generate \n
(newline) instead of \r
(carriage return) when the Enter key is pressed, causing commands to not execute properly on Windows terminals. The fix converts \n
to \r
when connecting from mobile/web-mobile platforms to Windows peers.
- Added logic to detect when the peer system is Windows
- Implemented newline-to-carriage-return conversion for mobile platforms connecting to Windows
- Added comprehensive comments explaining the cross-platform Enter key behavior differences
Comments suppressed due to low confidence (2)
flutter/lib/models/terminal_model.dart:40
- [nitpick] Modifying the input parameter 'data' directly can be confusing and makes the code harder to follow. Consider creating a new variable like 'processedData' to hold the converted value instead of reassigning the parameter.
data = '\r';
flutter/lib/models/terminal_model.dart:38
- [nitpick] The variable name 'isMobileOrWebMobile' is redundant and unclear. Consider renaming to 'isMobilePlatform' or 'shouldConvertNewline' to better express its purpose.
final isMobileOrWebMobile = (isMobile || (isWeb && !isWebDesktop));
Terminal connection, Android -> Windows, some keyboards generate
\n
when the Enter button is clicked.Windows requires
\r
to execute the command.Linux executes the command when it receives
\r
or\n
.