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 225749 - Formatting HTML inserts blank lines after semi-colon in attribute event handlers.
Summary: Formatting HTML inserts blank lines after semi-colon in attribute event handl...
Status: RESOLVED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 7.3
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Roman Svitanic
URL:
Keywords:
: 228140 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-02-05 13:49 UTC by brettryan
Modified: 2015-03-11 04:07 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 brettryan 2013-02-05 13:49:07 UTC
Given a statement such as the following:

    <a href="#" onclick="edit(${a.id});return false;">Edit</a>

Upon performing a format (Tools > Format) a new-line is placed after the semi-colon. This is undesirable behaviour and should be left to the author to decide in this situation where new-lines are inserted.

A very annoying secondary side-affect of this is when formatting script blocks that appear after such a line as above. Consider the following:

<div>
  <div></div>
</div>
<script>
  x();
</script>

When auto formatting the above remains as is, however, if we were to add an onclick inside the div element the script is indented by four spaces instead of two.

<div>
  <div onclick="x();"></div>
</div>
<script>
    x();
</script>

If there are further element nesting the indent level of the script becomes deeper and somewhat seemingly unpredictable in some circumstances.

Please note my HTML/Javascript indent level is two spaces.
Comment 1 Vladimir Riha 2013-05-23 07:39:41 UTC
*** Bug 228140 has been marked as a duplicate of this bug. ***
Comment 2 gugrim 2015-03-10 07:27:22 UTC
I suspect this bug also cause this behaviour:

Before formatting I had this attribute on a div in an Agular view:

ng-class="($first ? '' : 'hidden-xs hidden-sm')"

After formatting, NetBeans changed it into this: 

ng-class="($first ? '' : 'hidden - xs hidden - sm')"

This happens on NetBeans 8.0.2 and is pretty serious IMO. Since this bug not only causes ugly formatting but actually affects how the page works, a higher priority might be suitable.
Comment 3 brettryan 2015-03-10 08:14:45 UTC
Actually that is a pretty serious bug but would be a seperate issue and should be raised under web/angularjs. Not that in your example it only affects ng- attributes which are processed by the angular module in netbeans.
Comment 4 gugrim 2015-03-10 09:17:38 UTC
Reported as:

https://netbeans.org/bugzilla/show_bug.cgi?id=251057
Comment 5 Roman Svitanic 2015-03-10 15:45:56 UTC
Changeset: 2a3ffe5982cd
Author:    Roman Svitanic <rsvitanic@netbeans.org>
Date:      2015-03-10 16:46
Message:   #225749: Formatting HTML inserts blank lines after semi-colon in attribute event handlers - fixed
Comment 6 Quality Engineering 2015-03-11 04:07:06 UTC
Integrated into 'main-silver', will be available in build *201503110001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/2a3ffe5982cd
User: Roman Svitanic <rsvitanic@netbeans.org>
Log: #225749: Formatting HTML inserts blank lines after semi-colon in attribute event handlers - fixed
Task #225749 - Formatting HTML inserts blank lines after semi-colon in attribute event handlers.