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 188131 - Automatically closing editor files when they are deleted outside of IDE makes users loose data
Summary: Automatically closing editor files when they are deleted outside of IDE makes...
Status: REOPENED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 6.x
Hardware: PC Mac OS X
: P3 normal with 1 vote (vote)
Assignee: issues@editor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-27 21:09 UTC by austvik
Modified: 2010-07-04 09:13 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description austvik 2010-06-27 21:09:34 UTC
I used a couple of hours editing 4 new pom.xml files in NB 6.9 IDE
Then I ran hg ci -m "..." from the command line.

So far, so good, but I remembered that I had forgotten to do "hg pull -u", which is good to do before "hg ci", to minimize the number of merges.

I then did "hg backout tip" and "hg pull -u". I probably did something wrong here, because all my new files were deleted, without any .orig copies or anything.

No worry, I thought, they were open in NetBeans, all I had to do was to select the files in the editor and press "save". But as fast as I was able to activate the NetBeans window, the file tabs for the new files in the IDE were closed.

No trace of the files in NB, no trace of the files in the file system.

--

How I would like it to behave, and how other editors (emacs, MS visual studio) behaves: The files in the editor get the same status as new unsaved files when the underlying file in the file system is deleted. When I save the files, they are created with the content of the editor.

Also, NB does not create backup files (e.g. emacs "filename~"), so I lost two hours of work on this.

--

Even though I managed to delete my disk copy of the files, which triggered this, I think it is very serious that NB delete memory copy of user data, please triage accordingly.
Comment 1 austvik 2010-06-27 21:15:11 UTC
From the log:

INFO [org.netbeans.modules.editor.hints.AnnotationHolder]
org.openide.filesystems.FileStateInvalidException: MasterFileObject[/Users/austvik/opengrok/trunk/opengrok-indexer/pom.xml@5a5d13d4:3889bb23,valid=false]
        at org.openide.loaders.DataObject.find(DataObject.java:499)
Caused: org.openide.loaders.DataObjectNotFoundException: MasterFileObject[/Users/austvik/opengrok/trunk/opengrok-indexer/pom.xml@5a5d13d4:3889bb23,valid=false]
        at org.openide.loaders.DataObject.find(DataObject.java:519)
        at org.netbeans.modules.editor.hints.AnnotationHolder.getInstance(AnnotationHolder.java:145)
        at org.netbeans.modules.editor.hints.HintsControllerImpl.setErrorsImpl(HintsControllerImpl.java:108)
        at org.netbeans.modules.editor.hints.HintsControllerImpl.setErrors(HintsControllerImpl.java:93)
[catch] at org.netbeans.spi.editor.hints.HintsController$1.run(HintsController.java:79)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1957)
WARNING [org.netbeans.modules.openide.loaders.DataObjectEncodingQueryImplementation]: Invalid DataObject: /Users/austvik/opengrok/trunk/opengrok-indexer/pom.xml
WARNING [org.netbeans.modules.openide.loaders.DataObjectEncodingQueryImplementation]: Invalid DataObject: /Users/austvik/opengrok/trunk/opengrok-web/pom.xml
WARNING [org.netbeans.modules.openide.loaders.DataObjectEncodingQueryImplementation]: Invalid DataObject: /Users/austvik/opengrok/trunk/pom.xml
Comment 2 Marian Mirilovic 2010-07-01 07:33:34 UTC
This is as designed: IDE refreshes all files while focus is moving to the IDE, the reason is exactly the same as you described : external changes might affect the content you are currently working on in the IDE.
Comment 3 austvik 2010-07-01 07:47:07 UTC
This is very different from how other editors behave, and *leads to deleted user data*, which I think should be extremely high priority not to do.

I think the design is partly wrong (since it deletes users data and differs from other editors) and should be changed so that when a refresh happens.

If the file does not exist on disk: change file status to new and unsaved, but keep buffer open so that user data is available.

Please change from bug to feature request if you believe that this is "as designed", but please remove invalid, as it shouldn't be invalid to ask netbeans to not delete user data.
Comment 4 tarzanek 2010-07-02 09:22:11 UTC
well I am +1 for what jaustvik  says
this default design is not very user friendly

I think that IF a file is open in editor NB should ask you that the file was modified externally, if you want to update it (give the poor user an option to resolve the conflict himself)

obviously if a file is NOT open in editor NB can automagically update it (since there is no conflict) in its tree view
Comment 5 austvik 2010-07-04 09:13:22 UTC
How the other editors I have used behave:

** GNU Emacs 22.1.1 **
(Edit after changed content of file:)
test.file changed on disk; really edit the buffer? (y, n, r or C-h)

(Save after answering y on the previous question:)
test.file has changed since visited or saved.  Save anyway? (yes or no)

(Edit deleted file:)
Behaves as if the file is new.

** VIM - Vi IMproved 7.2 **

Saving changed file:
WARNING: The file has been changed since reading it!!!
Do you really want to write to it (y/n)?

(Writing deleted file:)
"test.file" [New] 

** Eclipse Galileo Version: 1.2.2.20100216-1730 **

(File edited outside editor:)
The file '.../test.file' has been changed on the file system. Do you want to replace the editor contents with these changes? (Yes, No)

(File deleted outside editor:)
The file '.../test.file' has been deleted or is not accessible. Yo you want to save your changes or close the editor without saving? (Close, Save)

** Visual Studio 2008 **
I don't have the exact text here, but if the file is changed it says something like "File has changed on disk, update buffer? (yes, no, cancel)"


I think it is safe to say that "automatically deleting users editor/buffer" is not the expected behavior.