Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newlines are Discarded from Code Copied to Clipboard #249

Open
vishnumaiea opened this issue Oct 3, 2023 · 14 comments
Open

Newlines are Discarded from Code Copied to Clipboard #249

vishnumaiea opened this issue Oct 3, 2023 · 14 comments

Comments

@vishnumaiea
Copy link

I just noticed that whenever I copy code using the Copy button, the code copied to the clipboard discards newlines (CRLF, etc.). You can see this on the following page.

https://www.circuitstate.com/tutorials/how-to-create-a-standalone-raspberry-pi-pico-c-cpp-project-in-windows-and-build-from-command-line-and-vs-code/

Simply copy any code there using the copy button and paste it into a notepad. The notepad contents look like below for me.

image

My actual code looks like below.

image

If copied by drag selection, it works as expected and the newlines are preserved when the code is pasted.

@vishnumaiea vishnumaiea changed the title Newliens are Discarded from Code Copied to Clipboard Newlines are Discarded from Code Copied to Clipboard Oct 3, 2023
@KevinBatdorf
Copy link
Owner

It doesn't happen locally when I try it but I see it happening on your site. Do you want to maybe list out your plugins or try deactivating them again? Not sure if you have that test site still set up.

CleanShot.2023-10-03.at.12.29.46.mp4

@vishnumaiea
Copy link
Author

Interesting. The staging site is sill up. Let me check.

@vishnumaiea
Copy link
Author

Found it. This time the culprit is the Flying Scripts plugin. It defers loading/executing Js until a user action happens. I use it to delay Google Ads. I have the following keywords to defer the Javascript. See any problem here?

adsbygoogle.js
reactive_library_fy2019.js
show_ads_impl_fy2019.js
recaptcha

@vishnumaiea
Copy link
Author

I tried removing each of the keywords one by one but had no effect even after removing all of them. Only when I deactivated the plugin, did the Copy button start working correctly.

@KevinBatdorf
Copy link
Owner

What's odd is the formatting is being changed before it's even in the browser. It could be because I used the attribute data-code and they are doing something with that.

CleanShot 2023-10-03 at 14 45 14

@vishnumaiea
Copy link
Author

For now, I will keep the Flying Scripts plugin deactivated. I don't see a performance impact even after disabling it. So it should be good.

@saranshkataria
Copy link

I had a similar issue with LiteSpeed cache. I fixed it by excluding front.js from the Deferred / Delayed JS pipeline.

@KevinBatdorf
Copy link
Owner

That's valuable feedback, thank you. I'll look into that

@MonzterDev
Copy link

I had a similar issue with LiteSpeed cache. I fixed it by excluding front.js from the Deferred / Delayed JS pipeline.

Hey, thanks a ton for your reply because I would have never resolved this issue without it! I'm still struggling to resolve this issue while the LiteSpeed Cache plugin is enabled. Similarly to you, I added the front.js file to all excludes inside of Page Optimization > [8] Tuning as you can see in the image below. That didn't seem to work for me, but I was able to track this issue back to the same plugin because the issue was resolved when I disabled it.

Page_Optimization_‹MonzterDev—WordPress-_Googl-05-05-24_04-02-36

@KevinBatdorf
Copy link
Owner

Thanks for the feedback. Can you link to the plugin? Ultimately, these html minification plugins/services shounld't be removing whitespace from within HTML attributes. At least not by default.

Is there a setting related to that under the HTML Settings tab there?

@MonzterDev
Copy link

Thanks for the feedback. Can you link to the plugin? Ultimately, these html minification plugins/services shounld't be removing whitespace from within HTML attributes. At least not by default.

Is there a setting related to that under the HTML Settings tab there?

Gonna take a look for that setting now, but in the meantime...here's a link to their Plugin, Github Repo, and Docs!

@MonzterDev
Copy link

Thanks for the feedback. Can you link to the plugin? Ultimately, these html minification plugins/services shounld't be removing whitespace from within HTML attributes. At least not by default.

Is there a setting related to that under the HTML Settings tab there?

It seems disabling the HTML Minify setting in the [3] HTML Settings tab solves this issue. I removed front.js from the excludes and as long as the HTML Minify setting was disabled, the copy feature functions as normal.

@KevinBatdorf
Copy link
Owner

Thanks for sharing the GitHub. i'll see if I can somehow add an exception so their code doesn't process it by default

@MonzterDev
Copy link

Thanks for sharing the GitHub. i'll see if I can somehow add an exception so their code doesn't process it by default

Wow, thanks for being outstanding! Fast replies, helpful solutions, and even looking into adding an exception... I really appreciate all the effort you put into creating and maintaining this plugin as well as helping those who use it! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants