ryboe / CSS3

The most complete CSS support for Sublime Text
MIT License
189 stars 28 forks source link

Add container short- and longhands #189

Closed vrugtehagel closed 1 year ago

vrugtehagel commented 1 year ago

Related issue: https://github.com/ryboe/CSS3/issues/184

This PR adds the container properties; the shorthand, container, and the longhands, container-name and container-size.

Should I add tests for these?

argyleink commented 1 year ago

should I add tests for these?

they're always welcome and pretty straight forward to add 👍🏻

argyleink commented 1 year ago

local tests of this look good 👍🏻

vrugtehagel commented 1 year ago

How do I go about that? Just list them in properties-list.py for each value?

vrugtehagel commented 1 year ago

So I did add the property-value combinations to properties-list.py - not sure how the testing actually works and whether I should be adding things to syntax_test_properties_c. Also I did notice that the highlighting for property values seems to just ignore order, but that may be by design. For example, if you do container: foo / none; then the none is technically not valid but gets highlighted as such since it'd be valid before the /. This behavior is already present in much older properties, though; if I name an animation alternate, it gets highlighted in an animation declaration as a keyword, even if it is used as ident.

If the lack of support for the value order is by design, then this PR is ready for another round of review; otherwise, please point me in the right direction.

As a sidenote, if it is by design, then my font shorthand PR would also be ready for review, since it suffers from the same issue.

argyleink commented 1 year ago

If the lack of support for the value order is by design

I can't answer this, but the original package author can if he's willing: cc @ryboe

ryboe commented 1 year ago

If the lack of support for the value order is by design

It was simply much harder to write regexes that enforce value order. Many of the regexes I was trying to write were so complicated that they were impossible to read or debug. So I gave up trying. I sacrificed the ability to detect out-of-order errors for regex simplicity.

That was the best I could do at the time, but this is not a law or anything. If there are certain properties where you think value order can be enforced and the regexes aren't too complicated, please feel free to write them the way you think is best 🙂

vrugtehagel commented 1 year ago

I honestly don't think it is worth the effort either; it seems unlikely people give their container the name inline-size or any of the other identifiers for container-type; and even if they do, having it highlight as a keyword instead of an ident is not the end of the world.