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

Local variables are randomly highlighted incorrectly. #59

Closed
ThadHouse opened this issue Apr 7, 2019 · 13 comments
Closed

Local variables are randomly highlighted incorrectly. #59

ThadHouse opened this issue Apr 7, 2019 · 13 comments
Assignees
Labels
🐛 Bug Something isn't working theme-color More related to theme than it is the syntax

Comments

@ThadHouse
Copy link

BlueNewWakeup

The postWakeup should not be highlighted with the same highlight as member variables. It's very distracting to not be consistent about this.

@matter123
Copy link
Collaborator

@jeff-hykin is going to need to resolve this one.

For now, you can restore 1.32 colorization with editor.tokenColorCustomizations setting.
Using the follow snippet:

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": "variable.other.object.access.cpp",
            "settings": {
                "foreground": "#BBB"
            }
        },
        {
            "scope": "punctuation.separator.pointer-access.cpp",
            "settings": {
                "foreground": "#B877dB"
            }
        }
    ]
}

Screenshot from 2019-04-06 21-54-42
You would want to change the colors to match your theme. For more information see #7.

@jeff-hykin
Copy link
Owner

I'll look at changing this behavior.
Right now postWakeup is marked as an object, wakeup is also marked as an object, connect is marked as a member variable.

All of those are tagged correctly, but I will look into changing the behavior to have wakeup tagged as both an object and a member variable.

@samkearney
Copy link

+1. The highlighting seems to change specifically when you use a dot or arrow operator on a variable, which leads to some confusing inconsistency.

See:
image

@matter123
Copy link
Collaborator

matter123 commented Apr 8, 2019

@jeff-hykin tagging wakeup as both an object and member variable would not solve @bootress's issue. Maybe in addition tag the first object in the chain as just variable.other. This would allow somone to make the root object (wakeup, sockets_ or sock_data) white via

"scope": "variable.other.cpp",
"settings": {
      "foreground": "#BBB"
}

Edit: composite image:
composite

@samkearney
Copy link

I just noticed that this highlighting inconsistency is also occurring in variable declarations:

image

@matter123
Copy link
Collaborator

That would be resolved by the proposal described at #61 (comment) where A B is tagged as a type and a variable

@jeff-hykin
Copy link
Owner

jeff-hykin commented Apr 10, 2019

I changed the tags to be the same as Java, Javascript, C# and some other languages.

If you want postWakeup to be colored white and the member variables to be colored blue then add the following to your TextMate color settings:

{
    "name": "off white",
    "scope":[
        "variable.other.object.access",
        ],
    "settings": {
        "foreground": "#c7cbcd",
        "fontStyle": ""
    }
},
{
    "name":"light blue",
    "scope":[
        "variable.other.object.property",
        "variable.other.property"
        ],
    "settings": {
        "foreground": "#89ddff",
        "fontStyle": ""
    }
},

Here's how it would look in your settings.json

        "editor.tokenColorCustomizations" : 
            {
                "textMateRules": [
                      // paste the above code HERE
                ]
            },

If you think it should be that way by default on your theme, then show them the above code and they should know what to do.

@jeff-hykin jeff-hykin added the theme-color More related to theme than it is the syntax label Apr 10, 2019
@jeff-hykin
Copy link
Owner

@ThadHouse Let me know if this is still an issue for you.

@ThadHouse
Copy link
Author

It seems really weird to not have the fix be the default. No intellisense colorizer I've ever seen for any language makes variable declarations different colors then variable usages. Its very off putting, and just looks bad. I notice the issue even more with checking shared_ptr's in an if statement, because inside the if, the variable is white, the declaration is right, yet as soon as a . or -> gets added it changes colors. It's just very confusing, and I suspect most users feel that way as well.

@ThadHouse
Copy link
Author

Also, the int var1 char var2[] issue bootress posted above is there as well, and thats even worse. They're both variable declarations, yet different. That's just wrong.

@samkearney
Copy link

I agree with @ThadHouse about the default behavior with regard to the original issue.

It looks like #71 has now been created to track my other issue with variable declaration.

@jeff-hykin
Copy link
Owner

@ThadHouse
I see what you mean.

Why this is happening

The syntax doesn't change the colors, it changes the knowledge that VS Code has, and then the theme uses that knowledge to color the code.

Right now one of the few times we know that something is a variable (specifically an object) is when an accessor ->, . is used on it. Since we have learned that, we have passed that knowledge on to VS Code for any extension or builtin functions to use. The code is being tagged as a variable, an object, and specifically an object that is having something accessed all of which are true statements.

The tags are standard across languages, so if you open up Java or Javascript your theme will likely color thing.member the same way it does in C++.

Themes likely have a blanket statement that sets all variables to a particular color, it just so happens that in C++ theres only a few times when we know something is more-than-likely a variable.

The underlying issue (I will make a new issue for this)

I think the fundamental issue is that the syntax should be able to see all variables. I would love that, and I'm willing to put in work to try to make that a reality, but sadly we are not there yet. Even more than that, I'm not even sure if it is possible with a TextMate grammar for the very syntax-bloated edgecase-filled confusing language that is C++.

What to do while we work on that

If you think the colors should be different, please ask the theme provider to set variable.other.object.access.cpp to be the same as the non-variable color. This will only affect the first item in a list of member-accesses ex: first.second.third.

If the theme providers disagree or don't respond, then add a color customization to your settings and it will override the theme.

@samkearney
Copy link

Thank you @jeff-hykin and @matter123 for your responsiveness. I understand that the scope of work involved here is very large, and I appreciate your willingness to tackle it!

@matter123 matter123 removed the 🔍 investigating More information is being gathered label Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working theme-color More related to theme than it is the syntax
Projects
None yet
Development

No branches or pull requests

4 participants