diff options
author | Cheng-Han, Wu | 2016-02-02 13:56:10 -0600 |
---|---|---|
committer | Cheng-Han, Wu | 2016-02-02 13:56:10 -0600 |
commit | 44ac1b295cfbe9e844d0739f7af7a7eee3c70ebf (patch) | |
tree | 9c0d51884198631f495cfbd86c229be8686b5ffd | |
parent | ce8f9b695cc524ee4678216912b6c899ca9976b7 (diff) |
Workaround for cut or paste action might make scrollMap not correct and big documents have poor input performance
-rw-r--r-- | public/js/index.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/public/js/index.js b/public/js/index.js index 6a152a14..b2a07ff3 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1813,12 +1813,32 @@ editor.on('beforeChange', function (cm, change) { if (cmClient && !socket.connected) cmClient.editorAdapter.ignoreNextChange = true; }); +editor.on('cut', function() { + windowResize(); //workaround for scrollMap +}); +editor.on('paste', function() { + windowResize(); //workaround for scrollMap +}); 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; + if (docLength > 20000) { + newViewportMargin = 1; + } else if (docLength > 10000) { + newViewportMargin = 10; + } else if (docLength > 5000) { + newViewportMargin = 15; + } + if (newViewportMargin != viewportMargin) { + viewportMargin = newViewportMargin; + windowResize(); + } }); editor.on('focus', function (cm) { for (var i = 0; i < onlineUsers.length; i++) { |