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: Handle new lines inside block string correctly #1637

Merged

Conversation

langpavel
Copy link
Contributor

@langpavel langpavel commented Dec 28, 2018

This fixes #1636

@langpavel
Copy link
Contributor Author

Hi @IvanGoncharov
Can I kindly ask you for review?
Thanks!

@IvanGoncharov
Copy link
Member

@langpavel Thanks for PR 👍
Please expand tests and I will merge this PR.

P.S. It's a good temporary solution but I don't like duplication of new line code handling and having special handling of block strings.
I think in long run we need to implement a common function for advancing lexer to the next character. Maybe even unify with CharacterStream from language server:
https://github.com/graphql/graphql-language-service/blob/master/packages/parser/src/CharacterStream.js

@langpavel
Copy link
Contributor Author

langpavel commented Dec 28, 2018

Ok, I will try refactor to new lexer method advanceLine, existing tests should cover this so no need to expand tests for block string
CharacterStream will be nice, but it will be huge change, (may be breaking..?)

@langpavel
Copy link
Contributor Author

@IvanGoncharov I extracted consumeNewline function so newlines are handled on one place.

@langpavel langpavel force-pushed the fix/lex-block-string-advance-line branch from 06ae24b to a44dcf8 Compare December 28, 2018 14:42
@IvanGoncharov
Copy link
Member

existing tests should cover this so no need to expand tests for block string

@langpavel Existing tests don't check that \r\n or \n\r advance line counter by one.

@langpavel
Copy link
Contributor Author

Ok, I will add more tests

@langpavel
Copy link
Contributor Author

@IvanGoncharov I added your test case and also added column assertion

@IvanGoncharov IvanGoncharov merged commit 42db579 into graphql:master Dec 31, 2018
@IvanGoncharov
Copy link
Member

@langpavel Thanks 👍
Merged 🎉

@langpavel
Copy link
Contributor Author

Thanks! Happy new year 🎉

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

Successfully merging this pull request may close these issues.

[lexer] Block string does not advance line
3 participants