Ionide-vscode-fsharp: Syntax highlighting

Created on 24 Sep 2018  路  8Comments  路  Source: ionide/ionide-vscode-fsharp

Hi,

Not even sure if this is an Ionide issue, but I thought I'd raise it here and see if you think it should be moved somewhere else.

Currently (latest Ionide) I still get a lot of wrong syntax highlighting, e.g.:

image

Is this something which can be improved easily? It's not a big issue, but something which would be nice to have working more consistently at some point.

Thank you!

If you need the code for testing:

let private MinimumCapacity = 5000
let private MaximumCapacity = 100000

type private StringBuilderPool =

    [<DefaultValue; ThreadStatic>]
    static val mutable private instance : StringBuilder

    [<DefaultValue; ThreadStatic>]
    static val mutable private created : DateTimeOffset

    static member Rent () =
        let lifetime = DateTimeOffset.Now - StringBuilderPool.created
        let expired  = lifetime > TimeSpan.FromMinutes 10.0
        let sb       = StringBuilderPool.instance
        if not expired && sb <> null then
            StringBuilderPool.instance <- null
            sb.Clear()
        else new StringBuilder(MinimumCapacity)

    static member Return (sb: StringBuilder) =
        if sb.Capacity <= MaximumCapacity then
            StringBuilderPool.instance <- sb
            StringBuilderPool.created  <- DateTimeOffset.Now

Most helpful comment

Moved both reports to separate issues in grammar repo.

All 8 comments

Hello,

Sorry for the bug, this is something that can be improved.

I wasn't aware of the syntax static val mutable private created : DateTimeOffset so the grammar doesn't detect it correctly. I will work on a fix in the grammar tomorrow.

Docs for reference

@MangelMaxime Yeah no worries. To be honest, if you maybe point me in the right direction I can try to do a PR as well.

@dustinmoris This new entry is probably tricky because it will need to handle balanced < & > expression for generics support.

If you want to give a try, please tell me so we are not both working on it. Here, are my first ideas on how to solve this problem.

We need to create a new entry to the grammar file, we can probably call it explicit_fields.

It needs to be placed in this list. And I believe it needs to be placed before the "#definition" entry.

Then we need to create the entry description, it's basically a regex and captures instruction to apply the correct scope to each group. However, this is going to be a complex entry because it needs to support balanced < & > characters in the type definition for generics support. There is already some entry that uses generic_declaration pattern.

Ok, then maybe I'll try another issue next time which is better suited for someone who has never done anything like that before, but thanks for sharing your ideas!

Yes working on the grammar can be challenging :)

If you want, we have some up for grabs issues.

Would you like me to create a new issue for a different issue with syntax highlighting @MangelMaxime?

image

Hello @seanpoulter yes please. You can create the issue here with a screenshot and if you can copy/paste the code in the issue so I don't have to type all by myself :)

Moved both reports to separate issues in grammar repo.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sivabudh picture sivabudh  路  3Comments

isaacabraham picture isaacabraham  路  5Comments

bruno-cadorette picture bruno-cadorette  路  4Comments

isaacabraham picture isaacabraham  路  4Comments

draganjovanovic1 picture draganjovanovic1  路  3Comments