From a516ee7b37b00e7a8f25fff1689ddcb5f056323a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 10 Nov 2014 12:07:26 -0500 Subject: [PATCH] feature(edit) keep cursor on same position after remote patch --- lib/client/edit.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index f16367e8..bdd71634 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -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); } }); }