Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 259362 - [Edit] Update diffs after undo
Summary: [Edit] Update diffs after undo
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Compare (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M6   Edit
Assignee: Pawel Pogorzelski CLA
QA Contact:
URL:
Whiteboard: hasPatch
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-19 08:25 EST by Tomasz Zarna CLA
Modified: 2009-06-02 07:07 EDT (History)
0 users

See Also:


Attachments
Patch_v01 (3.90 KB, patch)
2009-01-30 08:10 EST, Pawel Pogorzelski CLA
pawel.pogorzelski1: iplog+
Details | Diff
Patch_v02 (4.46 KB, patch)
2009-02-24 07:58 EST, Pawel Pogorzelski CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Zarna CLA 2008-12-19 08:25:36 EST
I20081216-0800

Steps:
1. Compare two files
2. Examines the differences
3. Do "Copy all non-conflicting changes..."
4. Click undo on the modified part
=> all the diffs are gone, even though the editor shows the same files content as in 2.
Comment 1 Pawel Pogorzelski CLA 2009-01-30 08:10:34 EST
Created attachment 124266 [details]
Patch_v01

The action "Copy all Non-Conflictiong Changes from Right to Left" is implemented by simple text replace on a widget. This triggers undo infrastructure below compare (actually it's in TextViewer) to store the operation in history. However when this happens the "Copy all..." is stored as a regular "Type" operation since information about the cause of document replacement is lost.

The workaround is to register an IOperationHistoryListener on a history and remember the operation added while "Copy all..." happens. The we can react on undo for that operation in TextMergeViewer.
Comment 2 Pawel Pogorzelski CLA 2009-01-30 08:15:21 EST
Just for the record, the workaround above was suggested by Dani.

He also said that as an alternative way it would be possible to provide a dedicated undo scenario.
Comment 3 Tomasz Zarna CLA 2009-02-24 06:10:07 EST
Patch works fine, but consider following scenario:

1. Compare two files, make sure only the right one has a change
2. Switch to Two-way compare if applicable
3. "Copy All Non-conflicting changes from Right to Left"
4. Diff is gone, good
5. Edit left side where the change from right has been copied
6. Save
7. A diff shows up, good
8. "Copy All Non-conflicting changes from Right to Left"
9. The diff is gone, good
10. Undo (back in 7), the diff reappears, good
11. Undo (back in 4), the diff is still there
=> Should disappear as we've just undone the copy-all-nonconflicts action from 3.

I guess a solution here would be to keep a collection of copy-all-nonconflicts operations, however the list doesn't have to be longer than undo history size. 
Comment 4 Pawel Pogorzelski CLA 2009-02-24 07:58:15 EST
Created attachment 126547 [details]
Patch_v02

Good catch Tomasz, thanks for testing. I thought it's impossible to have more than one of these actions in history. I was wrong, though.
Comment 5 Tomasz Zarna CLA 2009-03-03 07:10:43 EST
(In reply to comment #3)
> 11. Undo (back in 4), the diff is still there
> => Should disappear as we've just undone the copy-all-nonconflicts action from 3.

Sorry, this is not quite true, we've undone the edition made in step 5, my bad. We're are now in the state when we copied all nonconflicts (step 3), so there should be no diffs showed. It doesn't happen because the operation we've just undone is not a copy-all-nonconflicts operation but simple text edit and it's not kept in the undoableCopies collection. Anyway, the patch still doesn't work for the scenario from comment 3.
Comment 6 Tomasz Zarna CLA 2009-03-03 07:31:32 EST
Given the above, we decided to keep only the last copy-all-nonconflicts operation and react when undoing it. This means that we will stick to "Patch_v01".
Comment 7 Tomasz Zarna CLA 2009-03-03 07:32:56 EST
Released to HEAD, available in builds >N20090302-2000. Thanks for the patch Pawel, both of them ;)