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

Bug 388038

Summary: Eclipse deletes javascript code or replaces certain portions with "__$tag___" when using code formatting. I've lost my work.
Product: [WebTools] JSDT Reporter: eneerge Greene <eneerge>
Component: WebAssignee: Project Inbox <jsdt.web-inbox>
Status: CLOSED DUPLICATE QA Contact: Nitin Dahyabhai <thatnitind>
Severity: major    
Priority: P3 CC: daniel_megert, thatnitind
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description eneerge@eneerge.net Greene CLA 2012-08-24 19:06:51 EDT
I recently just configured Javascript formatting for Eclipse.  Unknowing that there could be a bug, I used ctrl+shift+f on a web page where I had implemented some javascript validation code.  I saved, deployed, and noticed I was getting strange Javascript errors.  I came back to my code in eclipse and noticed that parts of the Javascript code had been deleted and in places where I had Struts tags, it was printing ___$tag_____ in random locations.

I have pulled the archived code from a previous deployment to restore, and I notice that when I do ctrl+shift+f on a large chunk of javascript, it deletes my code.  Sometimes, but not every time, it will replace some code with $___$tag____.

It seems to occur only when I format a large chunk of code.  If I do one or two functions, it works fine.  If I highlight all of my Javascript, it deletes code every time.  I have around 200 lines of Javascript.  I have not experience any crashes, just loss of code.


-- Configuration Details --
Product: Eclipse 1.5.0.20120131-1544 (org.eclipse.epp.package.jee.product)
Installed Features:
 org.eclipse.platform 4.2.0.v20120608-135145-9JF7BHV8FyMteji0Oi_ePMz0xuZ8TVo7lV0z0ecb
Comment 1 eneerge@eneerge.net Greene CLA 2012-08-24 19:53:57 EDT
I've narrowed this down further and have been able to work around the issue by not using struts tags within the Javascript.

I can just create separate functions and write the logic tags within the html, rather than within the Javascript.  It's more code, and may be a bit harder to maintain, but it makes the code more readable and solves the formatting issue.
Comment 2 Nitin Dahyabhai CLA 2012-08-27 10:07:06 EDT

*** This bug has been marked as a duplicate of bug 382474 ***