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

Language Grammar Highlighting Messed Up? (Latest Insiders) #88997

Closed
bradennapier opened this issue Jan 20, 2020 · 8 comments
Closed

Language Grammar Highlighting Messed Up? (Latest Insiders) #88997

bradennapier opened this issue Jan 20, 2020 · 8 comments
Assignees
Labels
javascript JavaScript support issues semantic-tokens Semantic tokens issues
Milestone

Comments

@bradennapier
Copy link

bradennapier commented Jan 20, 2020

Version: 1.42.0-insider
Commit: d72b2d3
Date: 2020-01-20T05:27:44.927Z
Electron: 7.1.7
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.3.0

Steps to Reproduce:

  1. Open Javascript File
  2. Use code shown

I believe this has broken languages for me. I am using "Babel Javascript" and noticed with the most recent update that my color themes are screwed up.

  • It happens with the built in "Javascript" grammar as well as the "Babel Javascript" plugin
  • This happens with extensions disabled.
  • Interestingly the highlighting is actually correct until about 3-4 seconds after a window loads.
  • This happens when using default color themes as well
  • There does not appear to be any difference when I inspect the tokens - they refer to the same types.
  • Not sure if this is in latest insiders build, but it is main thing i see that could cause potentially that is recent? 852f493
  • Another potential culprit? fd13e44
  • Also noticed TypeScript brace matching is incorrect in ${} strings #88075

Recent Insiders Build:

image

image

image

Regular VSCode & Previous Insiders Builds:

image

image

image

const day = require('dayjs');
const SequelizeMysqlConnectionManager = require('sequelize/lib/dialects/mysql/connection-manager');
const abi = require('./abi');

const { env } = process;

Happen without Extensions?

Yes

@vscodebot vscodebot bot added the javascript JavaScript support issues label Jan 20, 2020
@bradennapier bradennapier changed the title Language Grammar Highlighting Messed Up? Language Grammar Highlighting Messed Up? (Latest Insiders) Jan 20, 2020
@IllusionMH
Copy link
Contributor

Probably same root cause as #88911

@mjbvz
Copy link
Collaborator

mjbvz commented Jan 21, 2020

Likely caused by semantic highlighting. Try setting "editor.semanticHighlighting.enabled": false to disable it

@aeschli
Copy link
Contributor

aeschli commented Jan 22, 2020

Not a bug but semantic highlighting that shows the actual type of the import based on the theme
yellow for functions, blue for variables.
If you don't like that information you can turn semantic highlighting off by
"editor.semanticHighlighting.enabled": false

@aeschli aeschli closed this as completed Jan 22, 2020
@mjbvz
Copy link
Collaborator

mjbvz commented Jan 22, 2020

@aeschli This is a major visual change that is going to cause a lot of issue reports against JS/TS. Are we shipping 1.42 with the semantic highlighting enabled by default? Anything we can do to reduce the impact?

@IllusionMH
Copy link
Contributor

IllusionMH commented Jan 22, 2020

@aeschli it's understandable how it works, but it brings few problems to JSX:

  1. It creates pale pale tree without almost no highlights if you use const Comp = () =>(<div>Hi</div>) because there is no color diff between <div>, <Comp /> and attribute name
    image
  2. It creates visual difference in tree between different implementation, but inside JSX thee all are used in the same way and difference should be between components and regular HTML tags
class CompCls extends React.Component{}

function CompFun() {}

const CompArr = () => {}
//or
const CompRef =  React.forwardRef(CompCls)

IMHO In this case semantic meanings shouldn't rely on original types, but differentiate between (custom) components, regular tags, and attributes. This is not in place currently.


So there is need to have extra info about cases when function/class/variable/property are used in tagName of JSX element.
And easy way to restore previous highlighs: green(-ish) for (custom) components, dark blue for tags, light blue for attributes that make sense in that place.

@aeschli
Copy link
Contributor

aeschli commented Jan 22, 2020

We can turn it off by default for stable, but we should work through the various issues.

  • imports (see example above): For me there's a value-add with semantic coloring. Of course there are still issues, such as what to do if a identifier is both a class and a variable.
  • JSX tags: I'll look at that. Obviously we don't want everything to become blue.

@aeschli aeschli added this to the onaco milestone Jan 22, 2020
@bradennapier
Copy link
Author

bradennapier commented Jan 22, 2020

There is more than just imports affected here. @aeschli maybe i dont understand specifically but for example a while statement is now yellow. sometimes my highlgithing is half words gray and half blue, will try to get screenshot when i can.

Other times imports have 3 different colorings - gray, yellow, blue based on my theme. How many colors are there now? Is there info on what this is doing exactly?

This seems to make the code really hard to read. I know i can turn it off, but i assume it is an ideal feature for other reasons and want to understand it before i just turn it off.

A bit confused why for statement is purple

image

and a while is yellow

image

I am guessing that it is trying to make functions one color and variables another, etc which is cool - I like that a lot. But seems inconsistent?

Like this chain state.db.updatedUsers changes the color after the first property is accessed

image

It very well could just be that my color theme isn't really setup well for the semantic highlighting ofc.

image

image

needless to say can definitely see this causing a huge stir if it is default in a release people randomly get hit with. do love the idea of syntax highlighting being smart though - that would be awesome if it produced code that is equally or even more easy to read and grok!

@aeschli aeschli modified the milestones: onaco, January 2020 Jan 23, 2020
@aeschli aeschli added the semantic-tokens Semantic tokens issues label Jan 23, 2020
@aeschli
Copy link
Contributor

aeschli commented Jan 23, 2020

@bradennapier Thanks for the help to find all the issues.

Semantic highlighting only looks at identifiers and resolves them to find out to what symbol they resolve.
You can use the Developer: Inspect Editor Tokens and Scopes hover to see what semantic type/modifier was given to an identifier.
We have a map that assigns each semantic token types to one or more textmate scopes. We query the theme for these scopes to evaluate the color to use.

Keywords are not touched. I tried to reproduce your example but I don't see any change for while. I'd like to understand why CONFIG.updateInterval gets different coloring. All identifiers should be classified as variable and get the color used for the variable color (scopes ['variable'], ['entity.name.variable'])

  • Please make sure you are on the latest i-build
  • What theme are you using?
  • Can you attach a small code sample (not just the screenshot)?
  • What does the Inspect Editor Tokens and Scopes hover show as semantic type and modifier.

@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
javascript JavaScript support issues semantic-tokens Semantic tokens issues
Projects
None yet
Development

No branches or pull requests

4 participants