Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Highlight unescaped multiline strings as invalid #209

Merged
merged 2 commits into from
Aug 26, 2015

Conversation

pchaigno
Copy link
Contributor

This pull request implements a change requested in #58.
Currently unescaped multiline strings are highlighted as if they were correct:

'line1
line2\
line3'

This change will highlight such strings as invalid.
Example of an invalid string with this change in Lightshow.

/cc @cydrobolt

@@ -31,6 +31,21 @@ describe "Javascript grammar", ->
expect(tokens[2].value).toEqual delim
expect(tokens[2].scopes).toEqual ["source.js", scope, "punctuation.definition.string.end.js"]

it "tokenizes invalid multiline strings", ->
lines = grammar.tokenizeLines("'line1\nline2\\\nline3'")
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice if you can span this over multiple lines instead of using \n (see examples further down)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@50Wliu
Copy link
Contributor

50Wliu commented Aug 26, 2015

Thanks a lot for this @pchaigno, tried solving this by myself a few weeks ago but couldn't get it to work.
Left some small feedback, and then it should be good to go.

@pchaigno
Copy link
Contributor Author

Thanks a lot for this @pchaigno, tried solving this by myself a few weeks ago but couldn't get it to work.

You're welcome. That was a tough one.
And there seem to be some differences in the way Atom and GitHub handle lookarounds. I'll check the implementation for GitHub later.

50Wliu added a commit that referenced this pull request Aug 26, 2015
Highlight unescaped multiline strings as invalid
@50Wliu 50Wliu merged commit 32197a8 into atom:master Aug 26, 2015
@50Wliu
Copy link
Contributor

50Wliu commented Aug 26, 2015

@pchaigno
Copy link
Contributor Author

🎉

@pchaigno pchaigno deleted the unescape-multiline-strings-invalid branch August 26, 2015 14:56
@cydrobolt
Copy link

👍

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

Successfully merging this pull request may close these issues.

None yet

3 participants