Less didn't compile properly on operations with parentheses
Installed product versions
- Visual Studio: Visual Studio Enterprise 2022
- This extension: 1.14.2
Description
Less didn't compile properly on operations with parentheses.
Steps to recreate
- Place an operation with parentheses in less file, for example :
width: (100px - 50px)/2; - Compile file to css
Current behavior
The result in css file is width: 50px/2;
Expected behavior
The result in css should be width: 25px;
Try adding another set of parentheses: width: ((100px - 50px)/2);
Yes it works with adding another set of parentheses.
But according to official less compiler (https://lesscss.org/less-preview/) it should work without adding another set of parentheses. It also works great with WebCompiler 1.12.394 by Mads Kristensen on VS2019.
I had similar errors after upgrading from a very old WebCompiler.
Resolved my errors and gained backward compatibility by addeing the math property to compilerconfig.json.defaults
"compilers": {
"less": {
"math": "always"
}
}
Thanks for this update, I'll look into the effects of this setting and see about adding it to the defaults for the next release.
Even border-radius: @card-border-radius / 2; does not compile.
Even
border-radius: @card-border-radius / 2;does not compile.
Add Parentheses
Even
border-radius: @card-border-radius / 2;does not compile.Add Parentheses
I have many many many of these occurrences which I don't want to change if I don't have to (is not having parenthesis illegal?). Anyway meixger's fix worked.
From lesscss.org
“From 4.0, No division is performed outside of parens using / operator.”
@failwyn: “From 4.0, No division is performed outside of parens using / operator.”
Should not be then marked division outside parentheses marked as error?
@TPIvan I don't have any control over that, Visual Studio needs better native support for LESS and SASS...