Skip to content

Commit cca5674

Browse files
committed
Fix on paste long document to editor might cause scroll not syncing
1 parent 2c58b05 commit cca5674

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

public/js/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,6 +2518,12 @@ editor.on('changes', function (cm, changes) {
25182518
windowResize();
25192519
}
25202520
checkEditorScrollbar();
2521+
if (editorHasFocus()) {
2522+
postUpdateEvent = function () {
2523+
syncScrollToView();
2524+
postUpdateEvent = null;
2525+
};
2526+
}
25212527
});
25222528
editor.on('focus', function (cm) {
25232529
for (var i = 0; i < onlineUsers.length; i++) {
@@ -2636,6 +2642,7 @@ function refreshView() {
26362642
var updateView = _.debounce(updateViewInner, updateViewDebounce);
26372643

26382644
var lastResult = null;
2645+
var postUpdateEvent = null;
26392646

26402647
function updateViewInner() {
26412648
if (currentMode == modeType.edit || !isDirty) return;
@@ -2668,6 +2675,8 @@ function updateViewInner() {
26682675
clearMap();
26692676
//buildMap();
26702677
updateTitleReminder();
2678+
if (postUpdateEvent && typeof postUpdateEvent === 'function')
2679+
postUpdateEvent();
26712680
}
26722681

26732682
var updateHistoryDebounce = 600;

0 commit comments

Comments
 (0)