This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 250038 - If-else on same line does not remove new line
Summary: If-else on same line does not remove new line
Status: VERIFIED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 8.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: Roman Svitanic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-27 07:02 UTC by Vladimir Riha
Modified: 2015-03-30 20:15 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Riha 2015-01-27 07:02:19 UTC
Please try following in JS file:

if (expr) {

}
else {

}


and in Tools|Options|Editor|Formatting, set if/else/else if to "Same Line". Once the code is formatted, I'd expect to get


if (expr) {

} else {

}


but nothing happens. The same works fine with

if (expr)
{

} else {

}

where the "if" part is formatted.


Thank you


Product Version: NetBeans IDE Dev (Build web-main-1841-on-20150127)
Java: 1.8.0_25; Java HotSpot(TM) Client VM 25.25-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_25-b17
System: Linux version 3.13.0-35-generic running on i386; UTF-8; en_US (nb)
Comment 1 Vladimir Riha 2015-01-27 07:27:29 UTC
The same goes for "else if"
Comment 2 Roman Svitanic 2015-03-25 12:49:21 UTC
This was caused by missing alignment options for new lines in JS. The state before reformat has been preserved. Now these options are available under Tools|Options|Editor|Formatting|JavaScript|Alignment options. By default the formatter will put else/while/catch/finally keywords on the same line as ending brace of if/do/try/catch (same as in Java and PHP).

Changeset: 266facf3ed31
Author:    Roman Svitanic <rsvitanic@netbeans.org>
Date:      2015-03-25 13:48
Message:   #250038 and #250039: Alignment options for new line before else/while/catch/finally keywords
Comment 3 Quality Engineering 2015-03-26 03:24:13 UTC
Integrated into 'main-silver', will be available in build *201503260001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/266facf3ed31
User: Roman Svitanic <rsvitanic@netbeans.org>
Log: #250038 and #250039: Alignment options for new line before else/while/catch/finally keywords
Task #250038 - If-else on same line does not remove new line
Comment 4 Vladimir Riha 2015-03-30 20:15:48 UTC
Thank you, verified

Product Version: NetBeans IDE Dev (Build 201503300001)
Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Linux version 3.13.0-45-generic running on amd64; UTF-8; en_US (nb)