-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undo/Redo cleanup #1510
Undo/Redo cleanup #1510
Conversation
…rface. This change makes TraitsUI undo items compatible with Pyface commands, making interoperation easier.
This fixes #1506.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a few comments/questions.
#: List of accumulated undo changes. Each item is a list of | ||
#: AbstractUndoItems that should be done or undone as a group. | ||
#: This trait should be considered private. | ||
history = List() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#: List of accumulated undo changes. Each item is a list of | |
#: AbstractUndoItems that should be done or undone as a group. | |
#: This trait should be considered private. | |
history = List() | |
#: List of accumulated undo changes. Each item is a list of | |
#: AbstractUndoItems that should be done or undone as a group. | |
#: This trait should be considered private. | |
history = List(List(Instance(AbstractUndoItem))) |
Is ^ the right trait definition - based on the docstring you added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should probably be List(List(Instance(ICommand)))
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I am hesitant to over-specify it as I would like to replace this state with an UndoManager
, so UndoHistory
is essentially just a wrapper around UndoManager
. Still investigating how much that actually breaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have decided to not make ths change for now.
removed=removed.copy(), | ||
) | ||
|
||
result = undo_item.merge(next_undo_item) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't fully understand why this behavior exists - why merging identical values (does that mean the same id
) is accepted but equal values doesn't work as expected. Is this a bug which was reported recently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is testing declared behaviour from this comment:
Lines 242 to 244 in 79b66f5
# Discard undo items that are identical to us. This is to eliminate | |
# the same undo item being created by multiple listeners monitoring the | |
# same list for changes: |
Since it is declared it should be tested that the code does what it says; if we feel that relaxing to equality is desirable, we should modify the code and the comment, but I don't have enough insight into whether that would be a problem.
Ah - just realized there is a missing piece in this. If we accept arbitrary |
Just so i'm clear, this PR is on hold until ^ changes are made? |
That plus the suggested doc fixes - this one is a spare-time effort. |
@rahulporuri I think this is good to go. This now:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM
"'merge_undo' is deprecated and will be removed in TraitsUI 8, " | ||
"use 'merge' instead", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll be useful to track this in an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
This PR does a number of things:
AbstractUndoItem
inherit fromAbstractCommand
(the interfaces were almost identical)AbstractCommand
interface which permits the use of arbitrary Pyface commands in the TraitsUI history interface.AbstractUndoItem
API then everything should still work.AbstractUndoItem.merge_undo
method in TraitUI 8 (in fact we can probably removeAbstractUndoItem
as well.This PR should be backward compatible, so can be included in the next minor release.
This is a safe first step for #1060.