stylus
stylus copied to clipboard
Do not indent userCSS style CSS rulesets within @-moz-document
- Browser: Firefox
- Operating System: All
- Stylus Version: 1.5.13
For userCSS styles, all rulesets inside every @-moz-document get indented. Since every ruleset is typically within a @-moz-document, this causes every ruleset to get indented. When the user doesn't want this, it makes it harder to write and edit userCSS styles.
Also if the functions within the @-moz-document are indented, every ruleset within the scope will get further indented!
For example, let's take this example of nice looking code:
@-moz-document domain("stackexchange.com"),
domain("askubuntu.com"),
domain("mathoverflow.net"),
domain("serverfault.com"),
domain("stackapps.com"),
domain("stackoverflow.com"),
domain("superuser.com") {
In this example, all rulesets inside the @-moz-document get indented by multiple tab stops! If you use tab stops of 3 or 4 characters, this issue gets amplified, as the number of tabs inserted before domain will have to increase to make the code visually appealing.
I tried toggle smart indent to see if it would help, but alas, it did not.
I'm thinking it is best to exclude @-moz-document as a trigger for auto-indentation.
You can enable Applies to widget : 
Sounds like a CodeMirror bug but it's worth investigating what we can do here anyway. Personally I like the indents and I don't see a single indent as a problem at all so we'll probably have an option for that or we'll try to be smart and adopt the indent of the first inner line.
Meanwhile, as a workaround for the multi-indent bug:
@-moz-document
domain("stackexchange.com"),
domain("askubuntu.com"),
domain("mathoverflow.net"),
domain("serverfault.com"),
domain("stackapps.com"),
domain("stackoverflow.com"),
domain("superuser.com") {
@tophf
I just ran some additional tests, and the "more than 1 tab indent" issue appears likely to be a CodeMirror bug. I will report it there as well.
Perhaps Stylus can implement a workaround, but the example you provided above is what I've been doing as a manual workaround.
Regarding a single indent, I think that's a personal style preference. Personally, I avoid indents that don't help me understand the code I'm writing. In this case, since everything gets indented, I don't find it helpful, as it only results in more horizontal scrolling of the code. It would be great if Stylus had an option to toggle that behavior.