Copying a code block does not include leading spaces

AI-generated summary

The discussion highlights a bug where using the copy button on a code block fails to preserve leading spaces. supermathie reports that on Chromium Linux, copying content from both posts and chat strips indentation, providing a test case showing the discrepancy between the visual block and the copied text. sam notes that this is a long-standing issue, tracing the bug back to the original implementation of the copy button by @justin in 2020.

Using the copy button[1] to copy a code block does not include any leading spaces.

Test case:

        GPU0    GPU1    NIC0    NIC1    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0    X       NV12    NODE    NODE    0-15            0               N/A
GPU1    NV12    X       PHB     PHB     0-15            0               N/A
NIC0    NODE    PHB     X       PIX                             
NIC1    NODE    PHB     PIX     X

What is actually copied:

GPU0    GPU1    NIC0    NIC1    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0    X       NV12    NODE    NODE    0-15            0               N/A
GPU1    NV12    X       PHB     PHB     0-15            0               N/A
NIC0    NODE    PHB     X       PIX                             
NIC1    NODE    PHB     PIX     X

Same thing happens in both posts and chat.

Chromium on Linux.


  1. ↩︎

2 Likes

This bug is ancient, it tracks all the way back to the original implementation of the button by @justin in 2020

1 Like