Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 370425

Summary: [formatting] Formatter inserts an extra line break before closing inline tag if there is some other inline tag inside.
Product: [WebTools] WTP Source Editing Reporter: Anton Obukhov <obukhovanton>
Component: wst.htmlAssignee: Salvador Zalapa <zalapa>
Status: ASSIGNED --- QA Contact: Nick Sandonato <nsand.dev>
Severity: normal    
Priority: P3 CC: thatnitind
Version: unspecifiedFlags: zalapa: review? (nsand.dev)
Target Milestone: 3.6.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Patch for the jsp.iu.test plugin none

Description Anton Obukhov CLA 2012-02-02 06:43:40 EST
Build Identifier: M20110909-1335

The HTML editor inserts extra line brakes before inline closing tag if there is some other inline tag inside.

Reproducible: Always

Steps to Reproduce:
1. Create an HTML file and open it with HTML editor.
2. Add some inline tag with a some other inline tag inside, for example:

<table>
<tr>
<td>One <b>Two</b> Three</td>
</tr>
</table>

3. Apply formating (Source -> Format)

The result is next:
<table>
    <tr>
        <td>One <b>Two</b> Three
        </td>
    </tr>
</table>

But should be:

<table>
    <tr>
        <td>One <b>Two</b> Three</td>
    </tr>
</table>

because of "td" is listed in the Inline Elements list in the Preferences -> Web  -> HTML Files -> Editor.
Comment 1 Salvador Zalapa CLA 2013-01-16 13:47:45 EST
<td>One <b>Two</b> Three</td> is not formatted correctly but
<td><b>Two</b> Three</td> is.

The thing is that the wallowsNewlineAfter() just honor the isInline() property when the firstChildType is an ELEMENT_NODE, and not when is a TEXT_NODE. I am adding an extra condition to handle this issue. I am also extended a junit to cover this.

junit: https://github.com/zalapa/webtools.sourceediting.tests/commit/101563c9c38d95ad07941519171037660b8a1aff

source: https://github.com/zalapa/webtools.sourceediting/commit/6739b13b93dd22b31139c0f4839e6080507e6d1a
Comment 2 Nick Sandonato CLA 2013-06-13 13:19:41 EDT
Looks good. Thanks for including a unit test for this as well.
Comment 3 Nick Sandonato CLA 2013-06-14 13:45:36 EDT
Hey, Chava. After looking a little closer, I think there might be a case where this might need touched up. You can see this if you run the jsp.core unit tests. It seems like it's not properly adding indentation if it's just whitespace text at the end of an element.
Comment 4 Salvador Zalapa CLA 2013-06-18 14:22:45 EDT
Thanks for your review Nick. In the next commit, i am using a different approach to just keep the inline the nodes are in the same line, I already run the HTML and the JSP test unit buckets. 

https://github.com/zalapa/webtools.sourceediting/commit/e292281e6438434e231badfcbb19aebaa19f776a
Comment 5 Salvador Zalapa CLA 2013-07-22 13:19:31 EDT
Created attachment 233678 [details]
Patch for the jsp.iu.test plugin
Comment 6 Salvador Zalapa CLA 2013-07-22 13:20:25 EDT
The patch from comment #4 still works, i also added the patch for the jsp.iu.test plugin.
Comment 7 Salvador Zalapa CLA 2013-07-24 12:54:37 EDT
Yes, I am in compliance with the Certifacte of Origin
Comment 8 Nick Sandonato CLA 2014-02-06 14:18:39 EST
3.5.2 is pretty much shut down at this point. Moving to Luna.