Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

newline_between_rules not working #158

Closed
hbj opened this issue Jul 6, 2017 · 9 comments
Closed

newline_between_rules not working #158

hbj opened this issue Jul 6, 2017 · 9 comments

Comments

@hbj
Copy link

hbj commented Jul 6, 2017

  • Operating System (+Version): Mac OS X El Capitan (10.11.6)
  • VS Code Version: 1.13.1
  • beautify Version: 1.1.1

VS Code:

{
  "beautify.ignore": [],
  "beautify.config": null,
  "editor.formatOnSave": true
}

.jsbeautifyrc

{
  "end_with_newline": true,
  "indent_size": 2,
  "max_preserve_newlines": 2,
  "wrap_line_length": 120,
  "newline_between_rules": true,
  "space_around_combinator": true
}

.editorconfig

# editorconfig.org

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

Action performed

Format a scss file (on save, format document and format selection).

Expected results

Expected formatted code to have empty lines between rules.

.main-header {
  .navbar {
    padding-left: 0;
    padding-right: 0;
  }

  > .social-icons {
    padding: 37px 0.5rem 5px 0;

    @include media-breakpoint-down(md) {
      display: none !important;
    }
  }

  .social-icons {
    a {
      display: block;
      width: 24px;
      height: 24px;
      margin-left: 0.25rem;
      margin-right: 0.25rem;
      background-repeat: no-repeat;
      background-position: center center;

      &.hubert_fb_url {
        background-image: url(../images/icon_facebook.svg);
      }

      &.hubert_twitter_url {
        background-image: url(../images/icon_twitter.svg);
      }

      &.hubert_pinterest_url {
        background-image: url(../images/icon_pinterest.svg);
      }
    }

    &.navbar-nav {
      margin-left: 0.5rem;

      a.nav-link {
        padding: 0;
        margin: $nav-link-padding;
        margin-left: 0.25rem;
        margin-right: 0.25rem;
      }
    }
  }
}

Actual results

Empty lines are removed.

.main-header {
  .navbar {
    padding-left: 0;
    padding-right: 0;
  }
  > .social-icons {
    padding: 37px 0.5rem 5px 0;
    @include media-breakpoint-down(md) {
      display: none !important;
    }
  }
  .social-icons {
    a {
      display: block;
      width: 24px;
      height: 24px;
      margin-left: 0.25rem;
      margin-right: 0.25rem;
      background-repeat: no-repeat;
      background-position: center center;
      &.hubert_fb_url {
        background-image: url(../images/icon_facebook.svg);
      }
      &.hubert_twitter_url {
        background-image: url(../images/icon_twitter.svg);
      }
      &.hubert_pinterest_url {
        background-image: url(../images/icon_pinterest.svg);
      }
    }
    &.navbar-nav {
      margin-left: 0.5rem;
      a.nav-link {
        padding: 0;
        margin: $nav-link-padding;
        margin-left: 0.25rem;
        margin-right: 0.25rem;
      }
    }
  }
}
@jporfirio
Copy link

Any updates on this yet?

@MushuPlatypus
Copy link

This would be very lovely to have

@giubatt
Copy link

giubatt commented Aug 22, 2017

+1
New release says it's was fixed but still doesn't work

@kbeaugrand
Copy link

+1

@xavierocampos
Copy link

I think the problem is that those rules you're applying only work in HTML, https://github.com/HookyQR/VSCodeBeautify/blob/master/Settings.md as you can see on this page, there is no rule that does that in CSS/SCSS.

If there's any way to do that, I'd like to know about it, because I don't like it either.

@hbj
Copy link
Author

hbj commented Sep 20, 2017

The rule 'newline_between_rules' is for CSS as per that document.

@xavierocampos
Copy link

You're very right, I just tested it and it works fine, tested on Windows 10 in Visual Studio Code version 1.16.1, use this example file to test: https://gist.github.com/wzup/fc3254562236c1ec3f69

@giubatt
Copy link

giubatt commented Sep 20, 2017

For scss it only works in the first level, for nested rules it doesn't leave a line between each rule, like the example in the OP

@davemac
Copy link

davemac commented Nov 4, 2017

I think the issue is with js-beautify itself. There is an open issue for it which the js-beautify devs are hoping to implement into a future release:

beautifier/js-beautify#1258

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants