The formatting when using a large amount of cases within a switch breaks

I was doing CoC, and saw that the formatting was breaking, displaying things as the string colour instead of the code colour.

as can be seen it has a lot of things orange when they shouldn’t be

(the code is:

#include <iostream>
using namespace std;
int main()
{
    string s;
    getline(cin, s);
    int t=0;
    for(int i=0;i<s.length();i++){
        switch(s[i]){
            case'a':
                t+=1;
                break;
            case'e':
                t+=2;
                break;
            case'i':
                t+=3;
                break;
            case'o':
                t+=4;
                break;
            case'u':
                t+=5;
                break;
            case'A':
                t+=2;
                break;
            case'E':
                t+=4;
                break;
            case'I':
                t+=6;
                break;
            case'O':
                t+=8;
                break;
            case'U':
                t+=10;
                break;
        }
    }
    cout<<t;
}

and is in c++

The highlighting got confused because you didn’t use a whitespace between case and the character.
image

2 Likes

Still a bug though, just now the main cause of it is known

The interesting part about it: it works on the official Monaco website. So something that CG did broke the highlighting for your code.

1 Like

We use the same syntax highlighting as the one from vscode.

It doesn’t work in vscode either.

vscode seems to use https://github.com/jeff-hykin/better-cpp-syntax, feel free to create an issue on their repo if you understand well the issue

This seems to be this bug:

1 Like