summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-05-16 23:02:59 +0800
committerCheng-Han, Wu2016-05-16 23:02:59 +0800
commit97befb6238f2a364c73f1158923a50f6b8752f7f (patch)
treee8e8c7f06d36101215b21e31c513b1f812b73d2e
parenteb5873a94d55528e944371c8fbae77a93201c8af (diff)
Fix on paste or cut text might trigger syncscroll
-rw-r--r--public/js/index.js4
-rw-r--r--public/js/syncscroll.js6
2 files changed, 8 insertions, 2 deletions
diff --git a/public/js/index.js b/public/js/index.js
index e47b8c18..7465044a 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -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) {
diff --git a/public/js/syncscroll.js b/public/js/syncscroll.js
index f0c7491b..de08ee39 100644
--- a/public/js/syncscroll.js
+++ b/public/js/syncscroll.js
@@ -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;