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.

Bug 138951 - Editing with MQ active deletes trailing whitespace from unrelated lines
Summary: Editing with MQ active deletes trailing whitespace from unrelated lines
Status: VERIFIED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Vitezslav Stejskal
URL:
Keywords:
: 139757 (view as bug list)
Depends on:
Blocks: 137529
  Show dependency tree
 
Reported: 2008-07-03 15:45 UTC by Jesse Glick
Modified: 2008-07-17 04:45 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2008-07-03 15:45:27 UTC
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.
Comment 1 Jesse Glick 2008-07-03 15:52:30 UTC
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?
Comment 2 Jesse Glick 2008-07-11 01:51:20 UTC
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.
Comment 3 Jan Becicka 2008-07-14 12:10:29 UTC
*** Issue 139757 has been marked as a duplicate of this issue. ***
Comment 4 Jan Becicka 2008-07-14 12:11:58 UTC
Mila is on vacation. He will be back next Monday.
Comment 5 Jesse Glick 2008-07-14 21:50:41 UTC
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?
Comment 6 Vitezslav Stejskal 2008-07-15 11:00:41 UTC
I'll have a look. I managed to reproduce the problem following the shorter version of your steps (no MQ involved).
Comment 7 Vitezslav Stejskal 2008-07-15 15:25:09 UTC
http://hg.netbeans.org/main/rev/0db6a516fc09
Comment 8 Jesse Glick 2008-07-15 15:44:52 UTC
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!
Comment 9 Quality Engineering 2008-07-17 04:45:16 UTC
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)