Skip to content

Newline characters are inserted into wordwrapped text #610

@postmodern

Description

@postmodern

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions