diff --git a/lib/editor-client.js b/lib/editor-client.js index a25373ee2..5c68ae9c9 100644 --- a/lib/editor-client.js +++ b/lib/editor-client.js @@ -138,7 +138,11 @@ firepad.EditorClient = (function () { var compose = this.undoManager.undoStack.length > 0 && inverse.shouldBeComposedWithInverted(last(this.undoManager.undoStack).wrapped); var inverseMeta = new SelfMeta(this.cursor, cursorBefore); - this.undoManager.add(new WrappedOperation(inverse, inverseMeta), compose); + + if (this.editorAdapter.ready) { + this.undoManager.add(new WrappedOperation(inverse, inverseMeta), compose); + } + this.applyClient(textOperation); }; diff --git a/lib/firepad.js b/lib/firepad.js index f8fe6993e..68997a952 100644 --- a/lib/firepad.js +++ b/lib/firepad.js @@ -132,6 +132,8 @@ firepad.Firepad = (function(global) { if (defaultText && self.isHistoryEmpty()) { self.setText(defaultText); } + + self.editorAdapter_.ready = true; self.trigger('ready'); }); diff --git a/lib/text-operation.js b/lib/text-operation.js index 4e1d26f02..3e9b98af9 100644 --- a/lib/text-operation.js +++ b/lib/text-operation.js @@ -452,6 +452,11 @@ firepad.TextOperation = (function () { // delete key. return (startB + simpleB.chars === startA) || startA === startB; } + + // undo text replace in one go + if (simpleA.isDelete() && simpleB.isInsert()) { + return startA === startB; + } return false; }; diff --git a/lib/undo-manager.js b/lib/undo-manager.js index c73ef1308..aaf94e42b 100644 --- a/lib/undo-manager.js +++ b/lib/undo-manager.js @@ -9,7 +9,7 @@ firepad.UndoManager = (function () { // Create a new UndoManager with an optional maximum history size. function UndoManager (maxItems) { - this.maxItems = maxItems || 50; + this.maxItems = maxItems || 500; this.state = NORMAL_STATE; this.dontCompose = false; this.undoStack = [];