postcss-language icon indicating copy to clipboard operation
postcss-language copied to clipboard

Syntax highlighting for nested elements is broken

Open marcofugaro opened this issue 4 years ago • 4 comments

When using nesting, the selectors are highlighted as css properties. They should be highlighted as selectors instead.

Current behaviour Expected behaviour
Screenshot 2020-07-15 at 17 29 45 Screenshot 2020-07-15 at 17 30 20

marcofugaro avatar Jul 15 '20 15:07 marcofugaro

@marcofugaro, you are correct. A goal of this language extension is to handle both the syntactically valid possibilities of https://www.w3.org/TR/css-syntax-3/ as well as those achievable in most PostCSS plugins.

As defined in the CSS syntax, your example would produce a faulty img declaration (thus the color coding) that never ends until the .wrapper closes. Reference: https://drafts.csswg.org/css-syntax/#consume-list-of-declarations

However, I believe PostCSS performs a special "look-ahead" to reconsume your code (lines 2-4) as an inner-rule. I think I can and should add this same ability to this language extension. Thanks for bringing this to my attention.

jonathantneal avatar Jul 17 '20 14:07 jonathantneal

Any updates on this?

Shaker-Hamdi avatar Jan 26 '22 12:01 Shaker-Hamdi

@Shaker-Hamdi, I ended up installing an alternative extension, PostCSS Intellisense and Highlighting. It handles nested syntax highlighting and Emmet abbreviations, and I haven't noticed any other issues.

From the description:

This extension is a mixed of two famous extensions postcss-language and vscode-postcss-language.

toddprouty avatar Jan 18 '23 15:01 toddprouty

@toddprouty this is what I ended up doing, albeit with some minor grumbling. As far as I know it uses the scss language server. I don't know enough about any of this to say if that's good or bad but it's probably not ideal!

SceptreData avatar Feb 26 '23 00:02 SceptreData