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.
The code which removes trailing whitespace is somehow getting confused by the file getting reloaded from disk while open in the editor, and considers all lines to have been "edited". I know this will sound obscure to be a P2, but in fact it is causing significant problems for those of us preparing patches using MQ - the patches are getting filled with unnecessary and distracting whitespace changes to dozens of lines (since most existing NB source has trailing spaces), making them harder to review, as well as being far more likely to fail to apply cleanly later. Reproduction is a bit complicated but you should be able to do it: 1. Run 080701 on fresh user dir. 2. Make a new Java Application project somewhere. 3. In Main.java, on the blank line before the final brace, enter " " and save. Move caret to top of file. This ensures that the trailing whitespace is committed to disk. 4. Install the Strip Whitespace plugin from AU. You should see the trailing whitespace in gray. 5. Versioning > Mercurial > Initialize Project 6. Commit on root node of project (so should now have clean status). 7. (from shell with CWD set to project basedir) hg qinit; hg qnew x.diff 8. Add to top of file (beneath package statement) in IDE's editor: import java.util.Date; Should be marked as an unused import. Save. Will still have original " " after main method. 9. hg qref; hg qpop 10. View editor; import gone. 11. hg qpush 12. View editor; import back. " " still there. 13. C-S-I to fix imports. Import gone; " " still there. 14. Save. " " disappears, even though no edits were made to this line. Seems that it is also possible to reproduce without using Mercurial: 1-4 as above. 8 as above. Make some unrelated change in the file using another text editor outside NB: e.g. add a blank line to start of file. Go back to IDE, which will reload showing the external change. 13 and 14 as above.
Also note that closing the open editor files before doing command-line MQ operations does not seem to help - perhaps because the documents are still loaded in memory?
Is this being evaluated? It makes it nearly impossible for me to work on patches using NB - I never know when saving a file is going to cause my diff to become 3x bigger. The problem is not limited to Fix Imports.
*** Issue 139757 has been marked as a duplicate of this issue. ***
Mila is on vacation. He will be back next Monday.
Since this is a serious problem - damaging file histories - perhaps trailing whitespace removal could be disabled until he gets back or someone else can investigate?
I'll have a look. I managed to reproduce the problem following the shorter version of your steps (no MQ involved).
http://hg.netbeans.org/main/rev/0db6a516fc09
Does seem fixed with the simplified test case at least. It is a signal irony that your patch is difficult to read because it is lost in the background of whitespace removal in BaseDocument.java!
Integrated into 'main-golden', available in NB_Trunk_Production #324 build Changeset: http://hg.netbeans.org/main/rev/0db6a516fc09 User: Vita Stejskal <vstejskal@netbeans.org> Log: #138951 (fixed): reset the list of modified areas when a document is reloaded (eg. after external modification to its underlying file)