Skip to content
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

Fix line normalization in Terminal.sendText() for IPython shell on Windows #238190 #238235

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

chiragjha1
Copy link

@chiragjha1 chiragjha1 commented Jan 19, 2025

Fix line normalization in Terminal.sendText() for IPython shell on Windows #238190

Issue:
The issue addresses line normalization in Terminal.sendText() function in IPython shells when run on Windows. The problem arises due to the line ending normalization in the code, this causes unexpected behavior in the terminal. Especially, when the sendText() method is used to send a Python function like hello_world(), IPython enters multi-line mode on Windows.

Solution:
Updated the line ending normalization logic in the sendText() method. This ensures:

  • Line endings are determined according to the platform:
    Windows uses \r\n
    Other platforms use \n
  • Line endings are normalized to the platform-specific endings, which solves the issue on Windows.
  • This also ensures that the text ends with the correct line ending if shouldExecute is true, this makes sure the method behaves as intended across platforms.

The modified code now checks for the platform and applies the appropriate line ending normalization, preventing the issue in the IPython shell.

How to Test:

  1. Set up an IPython shell in VSCode integrated terminal.
  2. On Windows, define a Python function that prints Hello, World!.
  3. From the terminal, send the command hello_world() using Terminal.sendText() method.
  4. Expected behavior: The function should execute correctly and the terminal should not enter the multi-line mode. The output would be Hello, world!
  • Please verify that this fix works across all major platforms as I lack the necessary resources to test this on macOS and Linux.

Make sure to adjust the "How to Test" section based on any specific details for your environment.

Before:
Before the Fix

After:
After the Fix

I'm a new contributor and open to feedback, do give this a commend if I'm wrong somewhere!

@chiragjha1
Copy link
Author

@microsoft-github-policy-service agree

@chiragjha1
Copy link
Author

Can I get some help with the errors?

Choose a reason for hiding this comment

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

Trying to figure it out

@meganrogge meganrogge assigned Tyriar and unassigned meganrogge Jan 21, 2025
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.

4 participants