mrcrowl / vscode-easy-less

Easy LESS extension for Visual Studio Code
MIT License
68 stars 22 forks source link

Bug when compiling #75

Closed Atronix1902 closed 3 years ago

Atronix1902 commented 3 years ago

Hey, just found a bug, which occurred since version 1.7.0. The compiler throws an error when I try to use my for-loop. image image

Since this still worked on version 1.6.3, I don't think it is my fault.

mrcrowl commented 3 years ago

Certainly not your fault 😃... this is due to an upstream change introduced in less v4.x where the math mode is "parens-division" by default (meaning that you have to wrap any math expression with a / in parentheses).

The default for less v3.x was "always", leading to the difference in behavior that you're experiencing.

Two ways to fix this:

  1. Wrap the expression containing / in parentheses: i.e. @i: (@index * 5 / 100);
  2. Add a math setting to your settings.json: e.g.
    {
      "less.compile": {
        "math": "always"
      }
    }

Ideally, you'd be able to set the math option in a per-file directive, but I've just tested and that isn't working atm. I'll try and get a separate release out for that.

mrcrowl commented 3 years ago

Per-file directive is now available in Easy Less v1.7.2.

i.e.

// math: always

@index: 17;
@i: @index * 5 / 100;

.padding-17 {
  padding: percentage(@i)
}