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

Bug 367579

Summary: [formatting] Formatting successive comments inserts spaces
Product: [WebTools] WTP Source Editing Reporter: Victor Homyakov <vkhomyackov>
Component: wst.cssAssignee: Salvador Zalapa <zalapa>
Status: RESOLVED FIXED QA Contact: Nick Sandonato <nsand.dev>
Severity: normal    
Priority: P3 CC: thatnitind
Version: unspecifiedFlags: nsand.dev: iplog+
nsand.dev: review+
Target Milestone: 3.5 M5   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Victor Homyakov CLA 2011-12-27 09:11:53 EST
1. Create CSS file with following content:
.class {
  background-color: #ccc /*#d4e2fc*/ /*#c3d9ff*/;
}
2. Format it two or three times (Ctrl-Shift-F).

Each time formatter inserts additional spaces between two comments, resulting in unlimited growth of line length and file size.

Eclipse: Eclipse Java EE IDE for Web Developers.
Version: Indigo Service Release 1
Build id: 20110916-0149
WTP: wtp-M-3.3.2-20111117045640
Comment 1 Victor Homyakov CLA 2012-07-06 04:28:04 EDT
Bug is still not fixed in Web Tools 3.4.0.
Comment 2 Salvador Zalapa CLA 2013-01-25 15:36:14 EST
This patch avoids the white space duplication:

https://github.com/zalapa/webtools.sourceediting/commit/78784a5cb355bcc47b444d9c3b66c9a6fde36e2a
Comment 3 Nick Sandonato CLA 2013-01-25 18:52:09 EST
Hi Chava, Thanks for looking into this. I think the patch looks good overall, however, the following testcase fails:

TestCSSDecl#testInsertPropertyInExistingRule

And also, if you could, please add a new test case to make sure we don't regress from this. Should be good after that.
Comment 4 Salvador Zalapa CLA 2013-01-28 11:06:00 EST
Thanks Nick for the review, in the previous patch i forgot to run the complete css test suite. I did just run the Formmatter tests, however my mistake was too simple, this is the fix for the previous patch.

https://github.com/zalapa/webtools.sourceediting/commit/c8693e3285948dedf47ad5146949cf39b50a7d51
Comment 5 Salvador Zalapa CLA 2013-01-28 11:41:32 EST
This is the junit part. I did a change the order in which the expected result are obtained, since right now it is getting the same result for a formatted and no formatted document, so the junit did not have any sense.

https://github.com/zalapa/webtools.sourceediting.tests/commit/c9b1bb569787525f8e3a3157f46382c7f6f58a95
Comment 6 Nick Sandonato CLA 2013-01-29 15:10:21 EST
Patch looks good. I've pushed your changes to master. Thanks, chava.