Community
Participate
Working Groups
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.
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.
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.
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.
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.
(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.
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".
Released to HEAD, available in builds >N20090302-2000. Thanks for the patch Pawel, both of them ;)