Skip to content

Commit 3590db3

Browse files
notriddleshepmaster
authored andcommitted
Prevent output pane text from being copied as HTML
Fixes rust-lang#840
1 parent 1b568f2 commit 3590db3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

ui/frontend/Output/SimplePane.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,19 @@ interface HighlightErrorsProps {
1010
label: string;
1111
}
1212

13+
const onOutputPrismCopy: React.ClipboardEventHandler = event => {
14+
// Blank out HTML copy data.
15+
// Though linkified output is handy in the Playground, it does more harm
16+
// than good when copied elsewhere, and terminal output is usable on its own.
17+
const selection = document.getSelection();
18+
if (selection) {
19+
event.clipboardData.setData('text/plain', selection.toString());
20+
event.preventDefault();
21+
}
22+
};
23+
1324
const HighlightErrors: React.FC<HighlightErrorsProps> = ({ label, children }) => (
14-
<div data-test-id="output-stderr">
25+
<div data-test-id="output-stderr" onCopy={onOutputPrismCopy}>
1526
<Header label={label} />
1627
<OutputPrism languageCode="language-rust_errors">
1728
{children}

0 commit comments

Comments
 (0)