modify implementation to support undo/redo in IDE editor