CodeEditorComponent undo/redo state updates


#1

Jules,

there’s a state update fail in CodeEditorComponent. You can see it in the Introjucer. Regular typing does not cause commandStatusChanged() to be called, so undo and redo are typically out of sync with whatever just happened. In fact as far as I can see, the only time the state gets changed is when a text highlight action occurs.

In the Introducer you can see this by opening a selecting a document that has not yet been changed, and typing some text. The undo state will show as unavailable. Similarly if you force an update by selecting something, then use undo, redo does not become available, and undo does not deactivate.

Looking quickly at the CodeEditorComponent it seems like newTransation() is being called repeatedly regardless of anything much happening, is this correct? If so, the only obvious fix I can see is to cache canUndo() and canRedo() and compare the values on the next call to newTransaction(). Is there a better fix for this?


#2

UndoManager is a ChangeBroadcaster - perhaps the code editor should register with it, and call commandStatusChanged() when it changes?