@@ -206,6 +206,42 @@ const handleSrcHighlight = (function() {
206
206
} ;
207
207
} ( ) ) ;
208
208
209
+ < << << << Updated upstream
210
+ // Workaround for https://github.com/rust-lang/rust/issues/141464
211
+ if ( navigator . userAgent . includes ( "Firefox" ) ) {
212
+ document . addEventListener ( "copy" , e => {
213
+ const text = nonnull ( window . getSelection ( ) ) . toString ( ) ;
214
+ nonnull ( e . clipboardData ) . setData ( "text/plain" , text ) ;
215
+ e . preventDefault ( ) ;
216
+ } ) ;
217
+ }
218
+ = === ===
219
+ // This section is a bugfix for firefox: when copying text with `user-select: none`, it adds
220
+ // extra backline characters.
221
+ //
222
+ // Rustdoc issue: Workaround for https://github.com/rust-lang/rust/issues/141464
223
+ // Firefox issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1273836
224
+ ( function ( ) {
225
+ document . body . addEventListener ( 'copy' , event => {
226
+ let target = event . target ;
227
+ let isInsideCode = false ;
228
+ while ( target !== document . body ) {
229
+ if ( target . tagName === 'CODE' ) {
230
+ isInsideCode = true ;
231
+ break ;
232
+ }
233
+ target = target . parentElement ;
234
+ }
235
+ if ( ! isInsideCode ) {
236
+ return ;
237
+ }
238
+ const selection = document . getSelection ( ) ;
239
+ nonnull ( event . clipboardData ) . setData ( 'text/plain' , selection . toString ( ) ) ;
240
+ event . preventDefault ( ) ;
241
+ } ) ;
242
+ } ( ) ) ;
243
+ > >>> >>> Stashed changes
244
+
209
245
window . addEventListener ( "hashchange" , highlightSrcLines ) ;
210
246
211
247
onEachLazy ( document . querySelectorAll ( "a[data-nosnippet]" ) , el => {
0 commit comments