inkle / inky

An editor for ink: inkle's narrative scripting language
http://www.inklestudios.com/ink
2.39k stars 290 forks source link

Syntax highlight breaks for this ink #15

Open joethephish opened 8 years ago

joethephish commented 8 years ago
== firstKnot
{ 
    - true:
        -> somewhere(5)
}

== somewhere(x)
Above knot declaration isn't highlighted.
-> DONE
Fahrengeit commented 8 years ago

Trying Windows version right now. Looks very cool. I think I won't need Sublime anymore :)

Found yet only one error - it happens after Help - Learn more. And I'm looking at highlighting, it has some issues in different situations.

"Well, here {!variable: I go|it goes}." Everyone, I suppose, knows, that if you want start a variable text with negation, you should use "not", so you won't mix it with Once-only list. Maybe it's better not to highlight "variable:" in that case, so user will know that it won't work how he expects.

"Well, here {not variable || anything: I go|it goes}." Logical operator || doesn't highlight correctly in variable text, Inky thinks that this one is operator of list and breaks highlighting though in runtime it works fine as logical operator.

I hope it helps in some way.

Fahrengeit commented 8 years ago

Hi. I am with some not so important things, but maybe this will help to close specifically this bug. What do you think, will this regexp work?

"#inlineConditional": [{
            regex: /(\{)(?!\s*(!|~|&))(([^:|\}]+(\|\|)*)+:)/,

I've tested it with Inky, at first glance it works and kills two cases at once (cases I've described in previous message). But I don't know yet if it can break anything else.

P.S. I'm wondering about this one expression:

token: "logic.sequence.punctuation", // | (but not ||)
regex: /\|(?!\|)/

Why should Inky stop highlighting "||" if it works and means that between there is an empty item. You can easily try something like that and it won't be an error: {First time||Third time} Or there is something else?

joethephish commented 8 years ago

Yep, that makes sense, I'll integrate the regex.

For the latter, the only reason I didn't accept it is out of lack of ambition for the correctness for the highlighter... but actually making it accept || by removing the negative lookahead seems to work fine, so I'll change that too. Thanks!

(Edit: in commit f20703862b8f486e93a7356f3a5068c19f21a643)