Community
Participate
Working Groups
Problem can be reproduce in PHP editor from pdt. Here are steps to reproduce: 1. Open external php file using Eclipse. 2. Make some changes. 3. Close editor, do not save changes. 4. Open the same file again in the same Eclipse instance. Result: All changes from point 2 are visible and file is dirty.
Created attachment 208933 [details] patch The problem is located in org.eclipse.dltk.internal.ui.editor.SourceModuleDocumentProvider. It is possible that when SourceModuleDocumentProvider.connect(Object) is called a new file info is added with a fake source module (line 1281 in SourceModuleDocumentProvider.createFileInfo(Object)) but it is not added to fFakeCUMapForMissingInfo map. During fake source module creation new buffer is created for it (org.eclipse.dltk.internal.ui.editor.DocumentAdapter). During its initialization (DocumentAdapter.initialize()) fFile is null so fileStore is stored in TextFileBufferManager (IFileBufferManager.connectFileStore(IFileStore, IProgressMonitor)). When file is closed fake copy is disconnected but only if file info is stored in fFakeCUMapForMissingInfo (in our case it does not). The second problem is in DocumentAdapter.close() method. It only disconnect buffer but does not disconnect fileStore (in our case only file store was connected). The result is that fileStore is not fully disconnected and when the file is opened again then modification are restored from it.
I was able to reproduce the bug. Checking the patch.
Created attachment 208985 [details] patch2 The fixes continue the changes started by bug 267008 "No validation for opened external files in PDT" (btw, how to check if it works?) There were 2 calls to create working copy, so now you need 2 calls to discard it. It doesn't feel correct, let's try if it can work with only 1 call. Please try how it works with my patch. Editor content is not cached, but I have no idea how to check the behavior of the mentioned bug 267008, even with PDT sources.
Your fix breaks bug 267008. To check it you need to break a code (e.g. line "echo 'hello world';" change to "echoo 'hello world';").
Finally, it looks like your patch does not affect on bug 267008 so it can be committed.
Patch2 committed.