Zulip Chat Archive
Stream: Zulip meta
Topic: Copying code now produces several blank lines
Mario Carneiro (Mar 24 2024 at 06:09):
Something seems to have changed with the selection behavior of code blocks. If I copy and paste the lines:
def foo := 1
def bar := 2
including previous text, I get
Something seems to have changed with the selection behavior of code blocks. If I copy and paste the lines:
def foo := 1
def bar := 2
where there are three blank lines before the code starts. When I select just the code I can sometimes get two blank lines before the code starts, and in other posts I've seen 5 lines and some whitespace too. This wasn't happening until recently. (I know, there is a "copy code" button I should probably be using instead, but this is weird anyway.)
Eric Wieser (Mar 25 2024 at 22:04):
On Chrome I get just one blank line
Eric Wieser (Mar 25 2024 at 22:05):
One thing that changed recently is that you can now select part of the original message, and the "quote and reply" button will quote just that part.
Julian Berman (Mar 25 2024 at 22:21):
On Firefox (124, macOS) I also just get one:
Something seems to have changed with the selection behavior of code blocks. If I copy and paste the lines:
def foo := 1
def bar := 2
Mario Carneiro (Mar 25 2024 at 22:22):
tried it again just now and got 6 blank lines (FF 123 + ubuntu)
Mario Carneiro (Mar 25 2024 at 22:26):
tried it in chromium and got 2 blank lines
Mario Carneiro (Mar 25 2024 at 22:27):
did it again and got 1.. what the heck
Mario Carneiro (Mar 25 2024 at 22:41):
I've narrowed it down to the usage of display: flex
in the div class="code-buttons-container"
used for holding the "copy code" and "view in playground" buttons. Even if I delete the contents of the div (those two buttons), I still get 3 blank lines, but if I disable display: flex
then I get 1 blank line in the selection
Mario Carneiro (Mar 25 2024 at 22:48):
Oh, I figured out at least a bit of the nondeterminism here: if I do the selection from top to bottom (shift-click body text, drag over code) then I get 2 blank lines, while if I do it the other way around (shift-click code, drag to body text) then I get 1 blank line in chromium. My guess is that this is because what gets copied depends on the display elements visible at the time I type ctrl-C, i.e. whether I'm currently hovering over the code such that the code buttons are visible
Mario Carneiro (Mar 25 2024 at 22:50):
doing likewise in FF reveals 3 blank lines when the code buttons are not hovered and 6 blank lines when they are
Kyle Miller (Mar 25 2024 at 22:53):
Mario Carneiro said:
I figured out at least a bit of the nondeterminism here: if I do the selection from top to bottom (shift-click body text, drag over code) then I get 2 blank lines, while if I do it the other way around (shift-click code, drag to body text) then I get 1 blank line in chromium
Can reproduce on Chrome on macOS
Alya Abbott (Mar 26 2024 at 04:36):
Thanks for the report! We implemented formatted text pasting fairly recently, so there may be kinks to iron out.
In the mean time, you can paste as plain text whenever that seems better (Ctrl-Shift-V, or the finger-tangling Option+Shift+Command+V on a Mac).
Last updated: May 02 2025 at 03:31 UTC