Closed smlombardi closed 5 years ago
What config do you use?
not sure. just the default, I suppose. I never set one up. I used to use the php version, then I installed the js version last week.
On Fri, Feb 14, 2014 at 4:33 PM, Tony Ganch notifications@github.comwrote:
What config do you use?
Reply to this email directly or view it on GitHubhttps://github.com/csscomb/csscomb.js/issues/177#issuecomment-35126900 .
I managed to reproduce this, thank you.
The problem is with parser, which treats selected text as valid css.
Since a bunch of declarations is not a valid rule, CSScomb fails to sort anything.
If you select the whole rule (including .utility-nav {...}
), it should work fine.
I can't see a way to tell the parser which part of css you want to comb: a rule or a list of properties. It means I can't think of a way to fix this.
I can see three ways of fixing this:
context
param, that would tell the parser in which context we are. This would actually would be a useful addition to the parser: we could then use it not only for the whole stylesheets, but also for any tools that are working with any individual items of the stylesheets, so if we'd like, we could parse a single declaration, or a part of the selector, or an rgba
function, or whatever.I'll vote for the third variant as it would be an overall enhancement to the parser, and I personally could then update the ST plugin so it would detect and pass the context of the selection to the parser.
@kizu, well, be my guest.
Plugin's source code: https://github.com/csscomb/sublime-csscomb
And Gonzales already accepts rule
parameter: https://github.com/tonyganch/gonzales-pe/blob/master/doc/Gonzales-Usage.md#css---ast
You know, I've implemented this "comb a selected part" feature in Sublime only because it'd been there in original (php) plugin. Now, after giving it some thought, I can't see a reason for the feature to be there at all. Can anyone give me a use case, please?
Case 1. I can suppose that in some cases (in preprocessors' code) you wouldn't want to comb everything, cause something could possibly go wrong after the sorting. For example, if this code:
@mixin foo {
width: 10px
}
.bar {
@include foo;
width: 20px;
}
would be combed to
@mixin foo {
width: 10px;
}
.bar
{
width: 20px;
@include foo;
}
then the resulting CSS would be different from the initial one. So, you wouldn't want to call CSSComb for the whole file, but would want to comb things you know wouldn't break.
Case 2. If you have a really big CSS file and don't want to run CSSComb through the whole file all the time, you could run it only for the new code you wrote.
Case 3. A developer of a foreign plugin could want to use CSSComb to comb the output of his/her plugin. For example, a plugin inserting snippets could want to insert them with the current detected style, but he wouldn't want the whole file to be combed. So this plugin would at first detect the style using CSSComb and the whole file, then insert new styles and then comb only them. Of course, the developer could do this to not-yet-inserted code, but this still would need the #179 to be implemented in order to comb only declarations etc.
Case 4. You could want to add new styles to a stylesheet that have a lot of bad uncombed code without any given code style. In this case there is no code style to use, so you could use any code style for your new code. In this case you could comb it by selecting it, but you wouldn't want to comb the whole stylesheet.
I used case 1 all the time
On Monday, February 17, 2014, Roman Komarov notifications@github.com wrote:
Case 1. I can suppose that in some cases (in preprocessors' code) you wouldn't want to comb everything, cause something could possibly go wrong after the sorting. For example, if this code:
@mixin foo { width: 10px} .bar { @include foo; width: 20px;}
would be combed to
@mixin foo { width: 10px;} .bar{ width: 20px;
@include foo;}
then the resulting CSS would be different from the initial one. So, you wouldn't want to call CSSComb for the whole file, but would want to comb things you know wouldn't break.
Case 2. If you have a really big CSS file and don't want to run CSSComb through the whole file all the time, you could run it only for the new code you wrote.
Case 3. A developer of a foreign plugin could want to use CSSComb to comb the output of his/her plugin. For example, a plugin inserting snippets could want to insert them with the current detected style, but he wouldn't want the whole file to be combed. So this plugin would at first detect the style using CSSComb and the whole file, then insert new styles and then comb only them. Of course, the developer could do this to not-yet-inserted code, but this still would need the #179https://github.com/csscomb/csscomb.js/pull/179to be implemented in order to comb only declarations etc.
Case 4. You could want to add new styles to a stylesheet that have a lot of bad uncombed code without any given code style. In this case there is no code style to use, so you could use any code style for your new code. In this case you could comb it by selecting it, but you wouldn't want to comb the whole stylesheet.
Reply to this email directly or view it on GitHubhttps://github.com/csscomb/csscomb.js/issues/177#issuecomment-35235947 .
cause something could possibly go wrong after the sorting
If there are bugs they should be fixed but not avoided. The example above will be ok in version 3.0, for example.
If you have a really big CSS file
Firstly, you don't run CSScomb every 5 seconds. Secondly, if the tool works so slow it hinders your work, this is a performance problem and should be fixed.
A developer of a foreign plugin could want to use CSSComb to comb the output of his/her plugin
I have nothing against adding context
parameter to processString()
method.
But it has nothing to do with Sublime plugin.
but you wouldn't want to comb the whole stylesheet
Why?
Closing as stale. If anyone is up for creating a PR head over to sublime-csscomb or open one at csscomb if needed.
Mac 10.9.1 ST3 3059 Stable. Nothing logged in console.