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

Fix failing with trailing comments in scripts #2674

Merged
merged 3 commits into from Nov 15, 2017

Conversation

Sxderp
Copy link
Contributor

@Sxderp Sxderp commented Nov 15, 2017

See #2670

When a user script had a trailing comment it would comment out part
of the eval string. Catch them so they don't interfere.

When a user script had a trailing comment it would comment out part
of the eval string. Catch them so they don't interfere.
(function scopeWrapper(){
function userScript() {
${this._content}
/* catch open comment blocks */ }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A) I prefer full/grammatical sentences in comments
B) Something like /* Force a line break after _content in case its final line contains a line comment. /* seems much more useful; just "catch open comment blocks" is so terse as to be hard to understand later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. Will adjust.

@@ -249,7 +249,11 @@ window.EditableUserScript = class EditableUserScript
// of the generated parts.
this._evalContent
// Note intentional lack of line breaks before the script content.
= `try { (function scopeWrapper(){ function userScript() { ${this._content} }
= `try {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the comment on the line above.

Adding a line after _content is good to fix this bug. Adding lines above it makes the lines in reported errors harder to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, missed that. I'll submit a commit the removes the lines.

@arantius arantius added this to the 4.1 milestone Nov 15, 2017
@arantius arantius merged commit b754b56 into greasemonkey:master Nov 15, 2017
@arantius
Copy link
Collaborator

This fix is in Version 4.1beta4. Testing to confirm the fix is appreciated!

https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/versions/beta?page=1#version-4.1beta4

@Sxderp Sxderp deleted the dont-fail-on-last-line-comment branch November 19, 2017 13:43
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

Successfully merging this pull request may close these issues.

None yet

2 participants