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

Tokenizer splitting ..< when a comment follows #61

Closed
angelolloqui opened this issue Nov 9, 2016 · 2 comments
Closed

Tokenizer splitting ..< when a comment follows #61

angelolloqui opened this issue Nov 9, 2016 · 2 comments

Comments

@angelolloqui
Copy link

This code:

1..<5

Results in this tokens:

po formatter.tokens
▿ 3 elements
  ▿ 0 : Token
    - number : "1"
  ▿ 1 : Token
    - symbol : "..<"
  ▿ 2 : Token
    - number : "5"

Which looks OK.

However, when adding a comment after the expression, then the tokenizer replaces .symbol("..<") with 2 tokens, a .symbol("..") and a .startOfScope("<"). Example:

1..<5
//comment

Results in:

po formatter.tokens
▿ 7 elements
  ▿ 0 : Token
    - number : "1"
  ▿ 1 : Token
    - symbol : ".."
  ▿ 2 : Token
    - startOfScope : "<"
  ▿ 3 : Token
    - number : "5"
  ▿ 4 : Token
    - linebreak : "\n"
  ▿ 5 : Token
    - startOfScope : "//"
  ▿ 6 : Token
    - commentBody : "comment"

The start of scope is a very delicate token because it makes other searches break, as everything after the < is in a different scope now.

@nicklockwood
Copy link
Owner

Nice catch!

By all means have a go at fixing it, or I'll tackle it myself this evening. Either way, a PR with a unit test to reproduce the issue would be much appreciated!

@nicklockwood
Copy link
Owner

Fixed in 0.17.1

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

2 participants