Newline characters are inserted into wordwrapped text
postmodern opened this issue · comments
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
- Enter a long String of
A
s greater than the width of the terminal:
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
- Copy and paste the entered text into a text editor.
- 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 A
s.
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
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
.
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.
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.