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

Newline characters are inserted into wordwrapped text #610

Closed
postmodern opened this issue Nov 21, 2023 · 3 comments
Closed

Newline characters are inserted into wordwrapped text #610

postmodern opened this issue Nov 21, 2023 · 3 comments

Comments

@postmodern
Copy link
Member

postmodern commented Nov 21, 2023

Description

I noticed that when entering text that is longer than 80 columns, the resulting word wrapped text has explicit newline characters inserted into it. This makes copying/pasting text from an IRB session into a text editor quite tedious.

Also note that only the input text which becomes word-wrapped contains the newline character. The output result which irb prints does not seem to contain any newline characters, and can be safely copy/pasted into a text editor as a single line.

Steps To Reproduce

  1. Enter a long String of As greater than the width of the terminal:

"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"

  1. Copy and paste the entered text into a text editor.
  2. Check whether the text was copied as a single line or two lines.

irb 1.9.1 (2023-11-21)

irb(main):003> "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
=> "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"

Note that a newline character, presumably inserted by irb, was preserved after copy/pasting the word-wrapped String of As.

irb 0.9.6(09/06/30)

irb(main):001:0> "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"

bash 5.2 (control)

I decided to test this against bash just to make sure it was not being caused by gnome-terminal. As one would expect, if you enter a very lone command into bash, and copy/paste it into a text editor, it displays as a single line even though the terminal word-wraps it to 80 columns.

[postmodern@dev bundler]$ echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

Terminal Emulator

gnome-terminal 3.48.1 using VTE 0.72.2 +BIDI +GNUTLS +ICU +SYSTEMD

@postmodern postmodern changed the title Newline characters are inserted into wordwrapped text Newline characters are inserted into wordwrapped text (#143) Nov 21, 2023
@postmodern postmodern changed the title Newline characters are inserted into wordwrapped text (#143) Newline characters are inserted into wordwrapped text Nov 21, 2023
@postmodern
Copy link
Member Author

This is an updated copy of issue #143. I re-tested the latest available version of irb on https://rubygems.org using bundler and bundle exec irb.

@tompng
Copy link
Member

tompng commented Nov 22, 2023

In input phase, (before you press Return key), it is hard to achieve this because Reline has dialog rendering.
When dialog is cleared/moved/resized, Reline re-renders input text which was hidden by dialog. Reline needs to clear "\n" for word wrapped lines in this phase and it's not easy.

After Return key is pressed and input is confirmed, it's possible to re-render the whole input without word wrap. #595 will fix this.

@ima1zumi
Copy link
Member

I will close this issue.

After Return key is pressed and input is confirmed, it's possible to re-render the whole input without word wrap. #595 will fix this.

#595 was transferred #614. #614 has been merged.

In input phase, (before you press Return key), it is hard to achieve this because Reline has dialog rendering.
When dialog is cleared/moved/resized, Reline re-renders input text which was hidden by dialog. Reline needs to clear "\n" for word wrapped lines in this phase and it's not easy.

We have no plans to implement this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants