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

Allow multi-line lookahead in modes #839

Closed
marijnh opened this issue Sep 20, 2012 · 5 comments
Closed

Allow multi-line lookahead in modes #839

marijnh opened this issue Sep 20, 2012 · 5 comments

Comments

@marijnh
Copy link
Member

marijnh commented Sep 20, 2012

Since patch 846d043 , the considerations that made lookahead past the current line problematic have largely been made irrelevant.

See discussion here

A mode would still have to declare its maxmimum lookahead, so that the parser frontier can be backed up appropriately when the document is edited. And it does muddle up the StringStream API a bit more (i.e. the various pieces of code that run parsers, such as runMode, need to somehow expose the whole document to the stream), but it's probably worth it.

@ForbesLindesay
Copy link
Contributor

Did this ever get looked at? I've been trying to update the JavaScript mode so that it recognizes functions as "in scope" even if they were declared after they were used. It's not proving easy...

@marijnh
Copy link
Member Author

marijnh commented Jun 3, 2014

This was only ever intended for simple, limited lookahead. Arbitrary lookahead like what you'd need to find all locals in a block won't be possible -- you'd have to do that with an out-of-line background scan, though wiring that up to a mode is also currently not trivial.

@cben
Copy link
Contributor

cben commented Aug 29, 2014

What about simple limited lookahead?
I'm specifically interested in markdown and rst underlined headers.
Could also be addressed with background scan + change event hooks doing markText(), but that's way harder to write correctly.
Also, if the scan wants to call getTokenAt() to use mode's parsing (e.g. to skip literal blocks) without replicating the whole mode, then it's no longer background; the sanest approach I see is replacing scan with renderLine (when mode has already run), calling markText under setTimeout(0)...

@superlou
Copy link

superlou commented Mar 9, 2015

Also interested in limited look-ahead, particularly for Fountain.io markup. I've been able to mostly implement highlighting by updating state with blank lines, but I think the canonical syntax definitions rely on look-ahead.

@marijnh
Copy link
Member Author

marijnh commented Jun 22, 2017

This was finally implemented in 5.27.0 (via the StringStream.lookahead method)

@marijnh marijnh closed this as completed Jun 22, 2017
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

4 participants