danro/LESS-sublime

Mixin indentation issue

richmilns opened this issue · 3 comments

I am using release 2.1.0 of this package.

I'm not too sure whether this is down to the syntax highlighting provided by this package or something else but I figured it was a good place to start!

What I've noticed is that the indentation of closing braces and brackets for certain less mixins seems to be incorrect.

Here's an example of an affected mixin:

.lg-up(@rules) {
    @media screen and (min-width: 990px) {
        @rules();
    }
}

What I have noticed when using the mixin is that if I run the command Indentation: Reindent Lines, I get this:

.lg-up({
    height:25vh;
    });

See the final brace and bracket? I would expect it to do this:

.lg-up({
    height:25vh;
});

Another example mixin:

.width-min-mq(@from, @rules) when (@support-media-queries = true) {
    @media screen and (min-width: @from) {
        @rules();
    }
}

Turns into this when the command Indentation: Reindent Lines is run:

.width-min-mq(800px, {
    color:red;
    });

Apologies is this nothing to do with the syntax highlighting this package provides but it only seems to happen in LESS so I thought I'd try to report it here first.

I've spotted an issue that's closed similar to mine: #91

#91 solves the highlighting issue, for this I may need to tweak the indentation rules. I'll look into it!

@richmilns the regexes that handle this are a bit complicated, but it seems that JavaScript has a ruleset that also works for LESS so I borrowed those. Seem to work better that the default. I will be testing it next week, and will release if it works well.