Fix on paste or cut text might trigger syncscroll

This commit is contained in:
Cheng-Han, Wu 2016-05-16 23:02:59 +08:00
parent eb5873a94d
commit 97befb6238
2 changed files with 8 additions and 2 deletions

View File

@ -822,7 +822,7 @@ function checkEditorScrollbar() {
// workaround simple scroll bar knob
// will get wrong position when editor height changed
var scrollInfo = editor.getScrollInfo();
preventSyncScroll = true;
if (!preventSyncScroll) preventSyncScroll = true;
editor.scrollTo(null, scrollInfo.top - 1);
editor.scrollTo(null, scrollInfo.top);
}
@ -2422,9 +2422,11 @@ editor.on('beforeChange', function (cm, change) {
cmClient.editorAdapter.ignoreNextChange = true;
});
editor.on('cut', function () {
preventSyncScroll = 3;
windowResize(); //workaround for scrollMap
});
editor.on('paste', function () {
preventSyncScroll = 3;
windowResize(); //workaround for scrollMap
});
editor.on('changes', function (cm, changes) {

View File

@ -257,7 +257,11 @@ function getEditorLineNoByTop(top) {
function syncScrollToView(event, _lineNo) {
if (currentMode != modeType.both) return;
if (preventSyncScroll) {
preventSyncScroll = false;
if (typeof preventSyncScroll === 'number') {
preventSyncScroll--;
} else {
preventSyncScroll = false;
}
return;
}
var lineNo, posTo;