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 242649 - Wrong formatting for inline JavaScript and CSS with different HTML formatting.
Summary: Wrong formatting for inline JavaScript and CSS with different HTML formatting.
Status: RESOLVED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 8.0
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Petr Hejl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-07 08:40 UTC by Christian Lenz
Modified: 2014-07-18 01:52 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Formatting Html (60.23 KB, image/png)
2014-03-07 08:40 UTC, Christian Lenz
Details
Formatting Javascript (66.00 KB, image/png)
2014-03-07 08:41 UTC, Christian Lenz
Details
Wrong formatting (23.50 KB, image/png)
2014-03-07 08:42 UTC, Christian Lenz
Details
Expected Formatting (24.04 KB, image/png)
2014-03-07 08:42 UTC, Christian Lenz
Details
Navigator (3.28 KB, image/png)
2014-03-07 08:42 UTC, Christian Lenz
Details
The AbstractIndenter patch (3.46 KB, patch)
2014-07-10 10:46 UTC, Marek Fukala
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Lenz 2014-03-07 08:40:46 UTC
Created attachment 145827 [details]
Formatting Html

When I set HTML formatting to indentation of 1 (See attachment FormattingHtml.png) and set JS formatting to indentation of 3 (See attachment FormattingJavascript.png) and I format the code, all inline CSS and JS will be formatted wrong, it will be formatted with the HTML formatting rules and not with its own (See attachment WrongFormatting.png and ExpectedFormatting.png).

I think as I see it inside the navigator, that he can recognize JS, CSS and HTML, than the rules should recognice it too. (See the attachment Navigator.png)


Regards

Chris
Comment 1 Christian Lenz 2014-03-07 08:41:30 UTC
Created attachment 145828 [details]
Formatting Javascript
Comment 2 Christian Lenz 2014-03-07 08:42:01 UTC
Created attachment 145829 [details]
Wrong formatting
Comment 3 Christian Lenz 2014-03-07 08:42:24 UTC
Created attachment 145830 [details]
Expected Formatting
Comment 4 Christian Lenz 2014-03-07 08:42:43 UTC
Created attachment 145831 [details]
Navigator
Comment 5 Vladimir Riha 2014-03-07 08:51:46 UTC
Reproducible

Product Version: NetBeans IDE 8.0 (Build 201403052200)
Java: 1.8.0; Java HotSpot(TM) Client VM 25.0-b69
Runtime: Java(TM) SE Runtime Environment 1.8.0-b131
System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)
Comment 6 Marek Fukala 2014-07-10 09:09:38 UTC
In another words it looks like the embedded languages always get the settings from the embedding language regardless what their own settings are.
Comment 7 Marek Fukala 2014-07-10 10:45:05 UTC
I tried to fix the AbstractIndenter so it gets proper settings for its language (it used to use IndentUtils.indentLevelSize(document) which always returned the top level language settings) but even if the AbstractIndenter.indentationSize property was correctly set, the indentation kept behaving wrong. 

When I set html indent level to 1, the html code was indented using level 4. Which is the opposite of the original state!?!?!

Javascript indenter/formatter doesn't seem to be extending/using web.indent/AbstractIndenter so it is either its fault it reads incorrect settings (as AbstractIndenter did) or the top level HTMLIndenter screws it up afterwards.

Anyway as the AbstractIndenter logic is not a code a feel familiar with, I'm passing this issue to David Konecny.

I'll attach a patch which IMO correctly fixes the way how the AI sets the indentationSize property.
Comment 8 Marek Fukala 2014-07-10 10:46:01 UTC
Created attachment 147969 [details]
The AbstractIndenter patch
Comment 9 David Konecny 2014-07-16 14:23:47 UTC
The root of the problem is in JavaScript indenter (I think). I fixed the HTML/CSS indenter to be capable of using different indent levels for different languages - 7d3660b27538. The fix is based on Marek's patch (thanks!) and expanded a bit.
Comment 10 Quality Engineering 2014-07-17 02:17:37 UTC
Integrated into 'main-silver', will be available in build *201407170001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/7d3660b27538
User: David Konecny <dkonecny@netbeans.org>
Log: #242649 - Wrong formatting for inline JavaScript and CSS with different HTML formatting.
Comment 11 Petr Hejl 2014-07-17 13:52:18 UTC
Fixed in web-main 7f53ae3f879c.
Comment 12 Quality Engineering 2014-07-18 01:52:32 UTC
Integrated into 'main-silver', will be available in build *201407180001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/cc1805fe3a06
User: Ondrej Brejla <obrejla@netbeans.org>
Log: Regenerated golden files in respect to fixes in issue #242649.