maintain scroll position on remote changes
This commit is contained in:
@@ -453,6 +453,7 @@ define([
|
|||||||
|
|
||||||
var onRemote = config.onRemote = function (info) {
|
var onRemote = config.onRemote = function (info) {
|
||||||
if (initializing) { return; }
|
if (initializing) { return; }
|
||||||
|
var scroll = editor.getScrollInfo();
|
||||||
|
|
||||||
var oldDoc = canonicalize($textarea.val());
|
var oldDoc = canonicalize($textarea.val());
|
||||||
var shjson = module.realtime.getUserDoc();
|
var shjson = module.realtime.getUserDoc();
|
||||||
@@ -475,6 +476,7 @@ define([
|
|||||||
var selects = ['selectionStart', 'selectionEnd'].map(function (attr) {
|
var selects = ['selectionStart', 'selectionEnd'].map(function (attr) {
|
||||||
return TextPatcher.transformCursor(oldCursor[attr], op);
|
return TextPatcher.transformCursor(oldCursor[attr], op);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(selects[0] === selects[1]) {
|
if(selects[0] === selects[1]) {
|
||||||
editor.setCursor(posToCursor(selects[0], remoteDoc));
|
editor.setCursor(posToCursor(selects[0], remoteDoc));
|
||||||
}
|
}
|
||||||
@@ -482,6 +484,8 @@ define([
|
|||||||
editor.setSelection(posToCursor(selects[0], remoteDoc), posToCursor(selects[1], remoteDoc));
|
editor.setSelection(posToCursor(selects[0], remoteDoc), posToCursor(selects[1], remoteDoc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editor.scrollTo(scroll.left, scroll.top);
|
||||||
|
|
||||||
var localDoc = canonicalize($textarea.val());
|
var localDoc = canonicalize($textarea.val());
|
||||||
var hjson2 = {
|
var hjson2 = {
|
||||||
content: localDoc,
|
content: localDoc,
|
||||||
|
|||||||
Reference in New Issue
Block a user