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

[ts] highlighting breaks with a complex type guard #237

Open
mtaran-google opened this issue Jan 19, 2019 · 3 comments
Open

[ts] highlighting breaks with a complex type guard #237

mtaran-google opened this issue Jan 19, 2019 · 3 comments

Comments

@mtaran-google
Copy link
Contributor

const predicate = (values: [T, B]): values is
                    [T & {a: B},
                     B] => {
                    }

highlights fine, but if you press enter right before the second values

const predicate = (values: [T, B]): 
values is
                    [T & {a: B},
                     B] => {
                    }

does not

@marijnh
Copy link
Member

marijnh commented Jan 21, 2019

The parser limits lookahead to two lines for performance reasons, and arrow function syntax is highly ambiguous until the arrow is seen—which with the extra newline here is more than two lines ahead from the first opening parentheses (the point where it has to decide what to parse).

We could look into loosening that, or move to a more fine-grained unit for the limit, like characters or tokens. Do you have any defined requirements or benchmarks for the highlighting performance?

@mtaran-google
Copy link
Contributor Author

Interesting! We don't have any specific metrics for highlighting performance since it's not generally been a problem before. I've only hit this issue in a somewhat contrived coding situation (but still a real piece of code I needed to write). Maybe let's try bumping up the limit to 3 lines (maybe just for TS, since we've not had this reported for other langauges?) and I can circle back if we notice any performance issues coming out of it.

marijnh added a commit to codemirror/grammar-mode that referenced this issue Jan 23, 2019
@marijnh
Copy link
Member

marijnh commented Jan 23, 2019

Okay, if you install codemirror-grammar-mode 0.1.8, that version has a max lookahead of 3 lines.

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