Skip to content

Commit 97befb6

Browse files
committed
Fix on paste or cut text might trigger syncscroll
1 parent eb5873a commit 97befb6

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

public/js/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ function checkEditorScrollbar() {
822822
// workaround simple scroll bar knob
823823
// will get wrong position when editor height changed
824824
var scrollInfo = editor.getScrollInfo();
825-
preventSyncScroll = true;
825+
if (!preventSyncScroll) preventSyncScroll = true;
826826
editor.scrollTo(null, scrollInfo.top - 1);
827827
editor.scrollTo(null, scrollInfo.top);
828828
}
@@ -2422,9 +2422,11 @@ editor.on('beforeChange', function (cm, change) {
24222422
cmClient.editorAdapter.ignoreNextChange = true;
24232423
});
24242424
editor.on('cut', function () {
2425+
preventSyncScroll = 3;
24252426
windowResize(); //workaround for scrollMap
24262427
});
24272428
editor.on('paste', function () {
2429+
preventSyncScroll = 3;
24282430
windowResize(); //workaround for scrollMap
24292431
});
24302432
editor.on('changes', function (cm, changes) {

public/js/syncscroll.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,11 @@ function getEditorLineNoByTop(top) {
257257
function syncScrollToView(event, _lineNo) {
258258
if (currentMode != modeType.both) return;
259259
if (preventSyncScroll) {
260-
preventSyncScroll = false;
260+
if (typeof preventSyncScroll === 'number') {
261+
preventSyncScroll--;
262+
} else {
263+
preventSyncScroll = false;
264+
}
261265
return;
262266
}
263267
var lineNo, posTo;

0 commit comments

Comments
 (0)