WebCompiler icon indicating copy to clipboard operation
WebCompiler copied to clipboard

Less didn't compile properly on operations with parentheses

Open initmaster opened this issue 3 years ago • 10 comments

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

  1. Place an operation with parentheses in less file, for example : width: (100px - 50px)/2;
  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;

initmaster avatar Feb 01 '22 06:02 initmaster

Try adding another set of parentheses: width: ((100px - 50px)/2);

failwyn avatar Feb 01 '22 12:02 failwyn

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.

initmaster avatar Feb 24 '22 16:02 initmaster

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"
  }
}

meixger avatar Mar 16 '22 16:03 meixger

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.

failwyn avatar Mar 16 '22 18:03 failwyn

Even border-radius: @card-border-radius / 2; does not compile.

pf-phill avatar Apr 21 '22 21:04 pf-phill

Even border-radius: @card-border-radius / 2; does not compile.

Add Parentheses

failwyn avatar Apr 22 '22 02:04 failwyn

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.

pf-phill avatar Apr 22 '22 02:04 pf-phill

From lesscss.org

“From 4.0, No division is performed outside of parens using / operator.”

failwyn avatar Apr 22 '22 02:04 failwyn

@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 avatar Oct 12 '22 13:10 TPIvan

@TPIvan I don't have any control over that, Visual Studio needs better native support for LESS and SASS...

failwyn avatar Oct 12 '22 14:10 failwyn