Skip to content

Commit 92bc271

Browse files
committed
Fixes firefox copy paste issue
1 parent 2b0274c commit 92bc271

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/librustdoc/html/static/js/src-script.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,15 @@ const handleSrcHighlight = (function() {
206206
};
207207
}());
208208

209+
// Workaround for https://github.com/rust-lang/rust/issues/141464
210+
if (navigator.userAgent.includes("Firefox")) {
211+
document.addEventListener("copy", e => {
212+
const text = nonnull(window.getSelection()).toString();
213+
nonnull(e.clipboardData).setData("text/plain", text);
214+
e.preventDefault();
215+
});
216+
}
217+
209218
window.addEventListener("hashchange", highlightSrcLines);
210219

211220
onEachLazy(document.querySelectorAll("a[data-nosnippet]"), el => {

0 commit comments

Comments
 (0)