Bug 152850 - [formatter] Formatter marks unchanged file dirty
Summary: [formatter] Formatter marks unchanged file dirty
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-04 11:51 EDT by Nick Veys CLA
Modified: 2007-03-20 13:31 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Veys CLA 2006-08-04 11:51:51 EDT
IIRC, the formatter is not supposed to touch a file if no changes are made to it.  The following class breaks this:

public class Test {
  /**
   * Any text
   * 
   * @param b
   */
  public void a(int b) {
  }
}

You can repeatedly Format, Save, Format, Save.  It always marks it dirty.  If you change it to:

public class Test {
  /**
   * @param b
   */
  public void a(int b) {
  }
}

It works as expected.  Also removing the @param and leaving the description text  works as expected as well.  Something with having both the description and @param tag (or any tag actually).  Which pretty much means every documented class.

An Undo will show a selected area of the whole blank line after the * up to the @ of the tag.
Comment 1 Dani Megert CLA 2006-08-04 12:27:43 EDT
Can reproduce using R3.2 or latest 3.3 build.
Happens as soon as there's a Javadoc comment.
Comment 2 Dani Megert CLA 2006-08-06 10:53:53 EDT
JDT Core gives us back edits.
Comment 3 Olivier Thomann CLA 2007-02-15 16:34:07 EST
We can detect that no edit are required.
I added an extra check when creating the optimized edits inside the scribe.
Released for 3.3M6.
Added regression test in org.eclipse.jdt.core.tests.formatter.comment.JavaDocTestCase#test152850
Comment 4 David Audel CLA 2007-03-20 13:31:49 EDT
Verified for 3.3 M6 using build I20070320-0010