Skip to content

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

Merged
merged 1 commit into from
Jul 19, 2025

Conversation

fufesou
Copy link
Collaborator

@fufesou fufesou commented Jul 18, 2025

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.

@fufesou fufesou requested a review from Copilot July 18, 2025 16:23
Copilot

This comment was marked as outdated.

@fufesou fufesou force-pushed the fix/terminal_handle_newline branch 2 times, most recently from f86e059 to 28d4db4 Compare July 18, 2025 16:27
@fufesou fufesou requested a review from Copilot July 18, 2025 16:27
Copilot

This comment was marked as outdated.

@fufesou fufesou requested a review from Copilot July 18, 2025 16:30
Copilot

This comment was marked as outdated.

@fufesou fufesou force-pushed the fix/terminal_handle_newline branch from 28d4db4 to 969bfab Compare July 18, 2025 16:43
@fufesou fufesou requested a review from Copilot July 18, 2025 16:43
Copilot

This comment was marked as outdated.

@fufesou fufesou force-pushed the fix/terminal_handle_newline branch from 969bfab to 8837590 Compare July 18, 2025 16:46
Signed-off-by: fufesou <linlong1266@gmail.com>
@fufesou fufesou force-pushed the fix/terminal_handle_newline branch from 8837590 to 0eebcc5 Compare July 18, 2025 16:57
@fufesou fufesou requested a review from Copilot July 18, 2025 16:59
Copilot

This comment was marked as outdated.

@fufesou fufesou requested a review from Copilot July 18, 2025 17:04
Copy link
Contributor

@Copilot Copilot AI left a 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));

@rustdesk rustdesk merged commit 555bb66 into rustdesk:master Jul 19, 2025
21 checks passed
@fufesou fufesou deleted the fix/terminal_handle_newline branch July 20, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy