revert changeSync event

pull/85/head
nightwing 2015-04-07 23:43:45 +04:00
rodzic 3644d203c2
commit cef4157eb3
1 zmienionych plików z 12 dodań i 12 usunięć

Wyświetl plik

@ -305,8 +305,7 @@ define(function(require, exports, module) {
this.deleyedEmit = lang.delayedCall(this._emit.bind(null, "change")) this.deleyedEmit = lang.delayedCall(this._emit.bind(null, "change"))
.schedule.bind(null, 0); .schedule.bind(null, 0);
undoManager.on("changeSync", this.deleyedEmit); this.setState(state, true);
this.setState(state);
} }
function updateDeltas(deltas) { function updateDeltas(deltas) {
if (deltas[0] && deltas[0].deltas) { if (deltas[0] && deltas[0].deltas) {
@ -321,22 +320,22 @@ define(function(require, exports, module) {
AceUndoManager.prototype = { AceUndoManager.prototype = {
add: function(delta, doc) { add: function(delta, doc) {
this.$aceUndo.add(delta, doc); this.$aceUndo.add(delta, doc);
this._emit("changeSync"); this._emit("change");
}, },
addSelection: function(range, rev) { addSelection: function(range, rev) {
this.$aceUndo.addSelection(range, rev); this.$aceUndo.addSelection(range, rev);
}, },
undo: function(dontSelect) { undo: function(dontSelect) {
this.$aceUndo.undo(dontSelect); this.$aceUndo.undo(dontSelect);
this._emit("changeSync"); this._emit("change");
}, },
redo: function(dontSelect) { redo: function(dontSelect) {
this.$aceUndo.redo(dontSelect); this.$aceUndo.redo(dontSelect);
this._emit("changeSync"); this._emit("change");
}, },
reset: function(){ reset: function(){
this.$aceUndo.reset(); this.$aceUndo.reset();
this._emit("changeSync"); this._emit("change");
}, },
canUndo: function() { canUndo: function() {
return this.$aceUndo.canUndo(); return this.$aceUndo.canUndo();
@ -346,11 +345,11 @@ define(function(require, exports, module) {
}, },
clearUndo: function() { clearUndo: function() {
this.$aceUndo.$undoStack = []; this.$aceUndo.$undoStack = [];
this._emit("changeSync"); this._emit("change");
}, },
clearRedo: function() { clearRedo: function() {
this.$aceUndo.$redoStack = []; this.$aceUndo.$redoStack = [];
this._emit("changeSync"); this._emit("change");
}, },
startNewGroup: function() { startNewGroup: function() {
return this.$aceUndo.startNewGroup(); return this.$aceUndo.startNewGroup();
@ -372,7 +371,7 @@ define(function(require, exports, module) {
position: stack.length - 1 position: stack.length - 1
}; };
}, },
setState: function(e) { setState: function(e, silent) {
console.log("setState()"); console.log("setState()");
var aceUndo = this.$aceUndo; var aceUndo = this.$aceUndo;
aceUndo.$undoStack = (e.stack || []).filter(function(x) { aceUndo.$undoStack = (e.stack || []).filter(function(x) {
@ -383,14 +382,15 @@ define(function(require, exports, module) {
var lastRev = lastDeltaGroup && lastDeltaGroup[0].id || 0; var lastRev = lastDeltaGroup && lastDeltaGroup[0].id || 0;
aceUndo.$rev = lastRev; aceUndo.$rev = lastRev;
aceUndo.$maxRev = Math.max(aceUndo.$maxRev, lastRev); aceUndo.$maxRev = Math.max(aceUndo.$maxRev, lastRev);
this.bookmark(e.mark); this.$aceUndo.bookmark(e.mark);
silent || this._emit("change");
}, },
isAtBookmark: function() { isAtBookmark: function() {
return this.$aceUndo.isAtBookmark(); return this.$aceUndo.isAtBookmark();
}, },
bookmark: function(rev) { bookmark: function(rev) {
this.$aceUndo.bookmark(rev); this.$aceUndo.bookmark(rev);
this._emit("changeSync"); this._emit("change");
}, },
bookmarkPosition: function(index) { bookmarkPosition: function(index) {
if (index > -1) { if (index > -1) {
@ -408,7 +408,7 @@ define(function(require, exports, module) {
} else { } else {
this.$aceUndo.bookmark(index); this.$aceUndo.bookmark(index);
} }
this._emit("changeSync"); this._emit("change");
}, },
addSession: function(session) { addSession: function(session) {
this.$aceUndo.addSession(session); this.$aceUndo.addSession(session);