Bug 165223 - Web Inspector: JS PrettyPrinting - multiline if conditions should be indented
Summary: Web Inspector: JS PrettyPrinting - multiline if conditions should be indented
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-11-30 14:30 PST by Joseph Pecoraro
Modified: 2016-12-13 15:35 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2016-11-30 14:30:17 PST
Summary:
Web Inspector: JS PrettyPrinting - multiline if conditions should be indented

Input:
if (a
    || b
    || c) {
  true;
}

Expected Output:
if (a
    || b
    || c) {
  true;
}

Actual Output:
if (a
|| b
|| c) {
  true;
}

Notes:
- The if statement's header (if (...)) should be indented in case it is multi-line (based on user's original formatting).
Comment 1 Radar WebKit Bug Importer 2016-11-30 14:30:38 PST
<rdar://problem/29446537>
Comment 2 Devin Rousso 2016-11-30 15:24:10 PST
IMO, this would be perfect for an item in the Settings tab.  Personally, I write my code to look exactly like the actual output, so I'd like to have the option to keep it like that.  Maybe something along the lines of "Match Indent of Multi-Line if with First Line" ¯\_(ツ)_/¯
Comment 3 Joseph Pecoraro 2016-11-30 15:33:33 PST
(In reply to comment #2)
> IMO, this would be perfect for an item in the Settings tab.  Personally, I
> write my code to look exactly like the actual output, so I'd like to have
> the option to keep it like that.  Maybe something along the lines of "Match
> Indent of Multi-Line if with First Line" ¯\_(ツ)_/¯

This would be too obscure on its own. Potentially if we had settings for other editing / formatting behaviors then it could be included in a group.

This formatting suggestion matches CodeMirror behavior, and WebKit style <https://webkit.org/code-style-guidelines/#indentation-wrap-bool-op> which is what we typically make our pretty printer do.