Skip to content

Commit 17ce882

Browse files
committed
Fixes firefox copy paste issue
1 parent 2b0274c commit 17ce882

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

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

209+
if (navigator.userAgent.includes('Firefox')) {
210+
document.addEventListener('copy', function(e) {
211+
const text = nonnull(window.getSelection()).toString();
212+
nonnull(e.clipboardData).setData('text/plain', text);
213+
e.preventDefault();
214+
});
215+
}
216+
209217
window.addEventListener("hashchange", highlightSrcLines);
210218

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

0 commit comments

Comments
 (0)