Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsThe problem of StructuredTextViewerUndoManager
https://www.eclipse.org/forums/index.php/mv/msg/54309/172937/#msg_172937
Originally posted by: eric_suen_cn.yahoo.com.cn
Hi,
I have code like this:
// model is an instanceof IStructuredModel
model.beginRecording(this);
e1.setAttribute(...);
e2.setAttribute(...);
model.endRecording(this);
I expect it will generate one CompoundCommand, but not works, because
StructuredTextViewerUndoManager.UndoNotifier listen selection event of
the TextViewer. if any selection changed, it will call the method
forceEndOfPendingCommand of class IStructuredTextUndoManager. If you
take a look of org.eclipse.jface.text.TextViewerUndoManager, you will
see it listen to the key and mouse event instead of selection event.
In StructuredTextViewer, if you typing some text then move cursor to
other offset then move back, then keep typing, it only generate one
command, but if you typing some text then change the selection then
move cursor back, then keep typing, it will generate tow undo command.
IMO, it is kind weird.
So, is it possible that my previous code only generate one command?
otherwise, this beginRecording, endRecording are totally useless...