From 37182382771e2194000ba36dadbf89b8f433e3b5 Mon Sep 17 00:00:00 2001 From: "Cheng-Han, Wu" Date: Wed, 20 Apr 2016 16:16:07 +0800 Subject: [PATCH] Fixed editor changes will cause syncScrollToView --- public/js/index.js | 4 ---- public/js/syncscroll.js | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/public/js/index.js b/public/js/index.js index 94ccc329..d19cc25a 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -2139,10 +2139,6 @@ editor.on('paste', function() { }); editor.on('changes', function (cm, changes) { updateHistory(); - preventSyncScroll = true; - var scrollInfo = editor.getScrollInfo(); - editor.scrollTo(null, scrollInfo.top - 1); - editor.scrollTo(null, scrollInfo.top); var docLength = editor.getValue().length; //workaround for big documents var newViewportMargin = 20; diff --git a/public/js/syncscroll.js b/public/js/syncscroll.js index 524d60a9..f0c7491b 100644 --- a/public/js/syncscroll.js +++ b/public/js/syncscroll.js @@ -115,8 +115,11 @@ var viewScrollingDelay = 200; var viewScrollingTimer = null; //editor.on('scroll', _.throttle(syncScrollToView, editorScrollThrottle)); -editor.on('scroll', syncScrollToView); -ui.area.codemirrorScroll.on('scroll', syncScrollToView); +if (editor.getOption('scrollbarStyle') === 'native') { + ui.area.codemirrorScroll.on('scroll', syncScrollToView); +} else { + editor.on('scroll', syncScrollToView); +} ui.area.view.on('scroll', function () { viewScrolling = true; clearTimeout(viewScrollingTimer);