feature(edit) keep cursor on same position after remote patch

This commit is contained in:
coderaiser 2014-11-10 12:07:26 -05:00
parent 77ece7d6cb
commit a516ee7b37

View file

@ -89,12 +89,17 @@ var CloudCmd, Util, DOM, CloudFunc, io, ace, DiffProto, diff_match_patch, Zip, M
Util.log(error);
} else {
sha(function(error, hash) {
var value;
var value, cursor;
if (hash === hashFS) {
value = Edit.getValue();
value = Diff.applyPatch(value, data);
Edit.setValue(value);
cursor = Ace.selection.getCursor();
Ace.setValue(value);
Ace.clearSelection();
Ace.moveCursorTo(cursor.row, cursor.column);
Ace.scrollToLine(cursor.row, true);
}
});
}