maintain scroll position on remote changes

pull/1/head
ansuz 8 years ago
parent c267dd6a88
commit 70f8837681

@ -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,

Loading…
Cancel
Save