diff --git a/www/code/main.js b/www/code/main.js index f3650ffa1..a106b532b 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -453,6 +453,7 @@ define([ var onRemote = config.onRemote = function (info) { if (initializing) { return; } + var scroll = editor.getScrollInfo(); var oldDoc = canonicalize($textarea.val()); var shjson = module.realtime.getUserDoc(); @@ -475,6 +476,7 @@ define([ var selects = ['selectionStart', 'selectionEnd'].map(function (attr) { return TextPatcher.transformCursor(oldCursor[attr], op); }); + if(selects[0] === selects[1]) { editor.setCursor(posToCursor(selects[0], remoteDoc)); } @@ -482,6 +484,8 @@ define([ editor.setSelection(posToCursor(selects[0], remoteDoc), posToCursor(selects[1], remoteDoc)); } + editor.scrollTo(scroll.left, scroll.top); + var localDoc = canonicalize($textarea.val()); var hjson2 = { content: localDoc,