Skip to content

css @media tag formatting doesn't respect line length #2198

Closed

Description

@mrsharpoblunto

When prettifying css, @media tags aren't broken up in a way that respects the max line length e.g.
I had the following

@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (   min--moz-device-pixel-ratio: 2),
only screen and (     -o-min-device-pixel-ratio: 2/1),
only screen and (        min-device-pixel-ratio: 2),
only screen and (                min-resolution: 192dpi),
only screen and (                min-resolution: 2dppx) {

Which was reformatted to

@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (-webkit-min-dev
ice-pixel-ratio: 1.5), only screen and (min--moz-device-pixel-ratio: 2), only screen and (-o-
min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (m
in-resolution: 192dpi), only screen and (min-resolution: 2dppx) {

Despite this exceeding the max line length. My expectation was that the nearest comma separated section of the media declaration would be split onto a new line in the same way as css selectors.

Activity

  1. added
    lang:css/scss/less
    help wanted
    on Jun 19, 2017
  2. vjeux commented on Jun 19, 2017

    @vjeux
    Contributor

    Thanks for the repro, it indeed should break it into multiple lines.

    It's not going to keep the whitespaces to align things though.

  3. added a commit that references this issue on Jun 21, 2017
    b3a1b79
  4. added a commit that references this issue on Jun 21, 2017
    313519d
  5. added
    locked-due-to-inactivity
    on Jul 7, 2018
  6. locked as resolved and limited conversation to collaborators on Jul 7, 2018
  7. added theissue type on Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedlang:css/scss/lesslocked-due-to-inactivity

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions