Open Bug 1528442 Opened 6 years ago Updated 2 months ago

Copying <pre> always adds newlines around it as <p> does

Categories

(Core :: DOM: Serializers, defect, P3)

65 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: richard.schneeman, Unassigned)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:65.0) Gecko/20100101 Firefox/65.0

Steps to reproduce:

Actual results:

In addition to the text that you expected to copy, there is an additional empty newline on every other line.

Video of the bug is attached.

Expected results:

When you paste, you should only get the lines of text and not the additional newlines. When you try the same behavior on the same page with chrome, it works.

The original video upload was too large, here's the same video on youtube https://www.youtube.com/watch?v=eSKXhobjFgk&feature=youtu.be

Component: Untriaged → Editor
Product: Firefox → Core
Priority: -- → P3

Seems that copying <pre> currently always adds newlines.

Have absolutely same annoying problem with Firefox. On Chrome no such problem.
Video with demonstration: https://yadi.sk/i/BUK8Qr2bZaQByQ
FF Version: 76.0 (64-bit)

Another example,

Steps to reproduce

Actual Output

Each line contains an extra new line.

5 4

1 2 1

1 3 2

3 4 1

3 5 3

2 1

4 2

2 6

5 10

Actual Output

Copied data should be as it's i.e. no new line after each line of code.

Same as Vipul's example but it happens only with KDE terminals such as Yakuake, Konsole

(In reply to dimanavsisto from comment #5)

it happens only with KDE terminals such as Yakuake, Konsole

Do you means, it only happens when you paste data in KDE terminal? Not in any text editor or place where you can paste your data.

(In reply to Vipul from comment #6)

(In reply to dimanavsisto from comment #5)

it happens only with KDE terminals such as Yakuake, Konsole

Do you means, it only happens when you paste data in KDE terminal? Not in any text editor or place where you can paste your data.

yes, only from Firefox to Yakuake, Konsole via Ctrl+Shift+V. If I paste to fish shell via Ctrl+V all fine, but not in vim or other console apps

I see this bug when I paste into sublime text 2, Evernote, and other text boxes in the Firefox browser.

It’s especially frustrating since I work support for Heroku and frequently copy and paste many lines of stack traces, I have to manually go back and remove all the lines.

Attached file bug1528442.html

This is about whether we want to add newline for blocks with default margins. Currently Firefox always adds newlines for both <p> and <pre> but Chrome adds newlines only for <p>.

I prefer adding newlines as it's more natural in this attachment. Using <pre> for every line as the example in comment #0 did is just like using <p> for every line.

That said, comment #4 uses a single <pre> block for each code block and the issue disappears if you open the DevTools, edit <body> with "Edit As HTML" just to remove event listeners, and copy the problematic blocks again. I suspect some javascript is causing the issue there.

Oh, this turns out to be a line ending issue where \r\n is incorrectly processed as double newlines.

Assignee: nobody → krosylight

Although I don't have concrete idea, if <pre> elements are adjacent siblings, line breaks between them might not be necessary for the comment 0's case especially when it has only one line content.

Component: DOM: Editor → DOM: Serializers
Summary: When copying multiple <code> lines, extra blank newlines are added between every line → Copying <pre> always adds newlines around it as <p> does
Assignee: krosylight → nobody

I see this is still set as "unconfirmed" can we set this to new? cc @hsinyi

(In reply to dimanavsisto from comment #7)

yes, only from Firefox to Yakuake, Konsole via Ctrl+Shift+V. If I paste to fish shell via Ctrl+V all fine, but not in vim or other console apps

It seems like Bug 1650720 is similar to Bug 1554489 (plaintext-serialization issue), that's if you paste data in text/html based editor like Libre Writer, data format will intact, may be Fish shell is also parsing pasted data in similar fashion.

I'm able to reproduce the behavior in vim using both iterm2 and terminal.app here is a screengrab of me copying and pasting into iterm vim https://imgur.com/a/xfhN3jU.

Any ideas here? Are you able to reproduce this behavior? I'm seeing it across 3~4 computers over 5 years including all of the editors anyone has mentioned here.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: