Open Bug 1760496 Opened 3 years ago Updated 1 year ago

Auto-format CSS (pretty-print) sometimes not activated

Categories

(DevTools :: Style Editor, defect, P3)

Firefox 98
Desktop
Linux
defect

Tracking

(Not tracked)

People

(Reporter: bugzilla.mozilla.reg, Unassigned)

References

(Blocks 2 open bugs)

Details

What were you doing?

It looks like minified JavaScript and CSS files are prettified automatically under Firefox devtools "Debugger" and "Style Editor" tabs, though sometimes CSS files aren't.

There is a prettify button for JavaScript "Debugger" tab, but the CSS "Style Editor" doesn't have this button. It would be nice if the Pretty-print button ({}) was also present for CSS, to be able to force the prettification.

https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Pretty-print_a_minified_file

Steps to reproduce:

  1. Go to 9 Frequently Asked Questions About Drupal 7 End of Life
  2. Open Firefox Developer Tools by pressing F12
  3. Open "Style Editor" tab and select one of the minified files, called something like https://evolvingweb.ca/sites/default/files/css/css_qkLw-ypd8IVtP6-cRYafRvyL3kVihApYx2epdKqNEOc.css
  4. See that is not prettified, but shown in one long line
  5. See that there is no Pretty-print button at the bottom

Is it maybe because the string .min isn't present in the file name?

What should have happened?

CSS should have been prettified, or the Pretty-print button ({}) shown, as an alternative to re-format the code.

Actual result:

Nothing happens.

Thanks for filing. I imagine the logic is at https://searchfox.org/mozilla-central/rev/1659f76981610c1b06437e0a34c0c232b48f4c93/devtools/shared/inspector/css-logic.js#229-233.

We'll need to check if that logic deserves to be updated or if we should just surface this to the user, and remove the "automated" pretty-printing.

I would rather go for the second option here.

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3
Whiteboard: [devtools-triage]

Thanks for responding to this so quickly.

We'll need to check if that logic deserves to be updated or if we should just surface this to the user, and remove the "automated" pretty-printing.

I would rather go for the second option here.

Right, there are pros and cons for auto-formatting. When it works it's great to immediately be able to read the code. On the other hand, sometimes the detection fails, and then you'd need a way to activate pretty-print ...

If skipping auto-detection and showing the pretty-print button by default is the simplest and fastest solution to build and roll out, I vote for that.

Let's try to both expose the feature and improve the automated pretty printing behavior.

Whiteboard: [devtools-triage]
You need to log in before you can comment on or make changes to this bug.