Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 326112

Summary: editor does not change the dirty status after save it.
Product: z_Archived Reporter: Zhongwei Zhao <zhaozhongwei>
Component: PDTAssignee: Zhongwei Zhao <zhaozhongwei>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: ganoro, os-dev, petyo_tanchev
Version: unspecifiedFlags: ganoro: review-
zhaozhongwei: review? (qiangsheng.w)
zhaozhongwei: review? (zhaozhongwei)
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
patch none

Description Zhongwei Zhao CLA 2010-09-24 01:11:08 EDT
for example
use file->convert line endings and then save the file
               
Actual Result:
the file is marked as changed (asterisk on the tab), but i can't save it without making some other change to the file, (Adding a space or something)
Comment 1 Zhongwei Zhao CLA 2010-09-24 01:13:19 EDT
Created attachment 179496 [details]
patch
Comment 2 Roy Ganor CLA 2010-09-26 18:00:12 EDT
I couldn't understand the flow of the isDirty() method, can you take a look t this fix:

@Override
public boolean isDirty() {
	// if super.isDirty() return false,it means this
	if (!super.isDirty()) {
		return false;
	}
	if (getDocument() instanceof IStructuredDocument) {
		CommandStack commandStack = ((IStructuredDocument) getDocument())
					.getUndoManager().getCommandStack();
		if (commandStack instanceof BasicCommandStack) {
			BasicCommandStack bcs = (BasicCommandStack) commandStack;
			return bcs.isSaveNeeded();
		}
	}

	return true;
}
Comment 3 Zhongwei Zhao CLA 2010-09-26 22:42:14 EDT
Hi Roy

I retest my patch and found there is problem with it,and I thought something wrong before!
You code is fine to me:)
Comment 4 Jason Craig CLA 2010-09-28 01:27:49 EDT
Using version 2.2.1.v20100822-1200, this appears to be a regression in Helios SR1.  When you save a PHP file for which a "save action" takes place, the file is still marked unsaved or dirty but you are not able to save it until you make a change that doesn't require the save action.

Steps to reproduce:
1) Go to preferences, PHP -> Editor -> Save Actions.  Make sure "Remove trailing whitespace" is checked and that "all lines" is selected.
2) Edit a PHP file.
3) Make a change to the PHP file that will require the save action to be performed (e.g. add whitespace to the end of a line or create a new line that has only whitespace characters...or convert line endings like zhaozhongwei, which probably introduced such a change).
4) Save the file using any method you prefer.
5) Note that the file does get saved (after the save action performed), however the editor believes that the file is still dirty.

I would imagine also that bug 326120 is a duplicate.
Comment 5 Zhongwei Zhao CLA 2010-09-28 01:51:28 EDT
(In reply to comment #4)
> Using version 2.2.1.v20100822-1200, this appears to be a regression in Helios
> SR1.  When you save a PHP file for which a "save action" takes place, the file
> is still marked unsaved or dirty but you are not able to save it until you make
> a change that doesn't require the save action.
> 
> Steps to reproduce:
> 1) Go to preferences, PHP -> Editor -> Save Actions.  Make sure "Remove
> trailing whitespace" is checked and that "all lines" is selected.
> 2) Edit a PHP file.
> 3) Make a change to the PHP file that will require the save action to be
> performed (e.g. add whitespace to the end of a line or create a new line that
> has only whitespace characters...or convert line endings like zhaozhongwei,
> which probably introduced such a change).
> 4) Save the file using any method you prefer.
> 5) Note that the file does get saved (after the save action performed), however
> the editor believes that the file is still dirty.
> 
> I would imagine also that bug 326120 is a duplicate.

have tried:
add whitespace to the end of a line or create a new line that has only whitespace characters...or convert line endings.I think it has been fixed already.
Comment 6 Jason Craig CLA 2010-10-04 15:59:08 EDT
As FYI I also found that if you use search to find a string that is in a PHP file, then you right click on a search result and do "replace selected..." or "replace all..." it exhibits this behavior.  Also if you right click on a file and select "replace with" -> "local history..." it happens too.

Can you make sure these are fixed too?  Thanks.
Comment 7 Petyo Tanchev CLA 2010-10-07 03:29:49 EDT
Tested on 2.2.1.v20101001
Fixed