Workaround for cut or paste action might make scrollMap not correct and big documents have poor input performance
This commit is contained in:
parent
ce8f9b695c
commit
44ac1b295c
1 changed files with 20 additions and 0 deletions
|
@ -1813,12 +1813,32 @@ editor.on('beforeChange', function (cm, change) {
|
||||||
if (cmClient && !socket.connected)
|
if (cmClient && !socket.connected)
|
||||||
cmClient.editorAdapter.ignoreNextChange = true;
|
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) {
|
editor.on('changes', function (cm, changes) {
|
||||||
updateHistory();
|
updateHistory();
|
||||||
preventSyncScroll = true;
|
preventSyncScroll = true;
|
||||||
var scrollInfo = editor.getScrollInfo();
|
var scrollInfo = editor.getScrollInfo();
|
||||||
editor.scrollTo(null, scrollInfo.top - 1);
|
editor.scrollTo(null, scrollInfo.top - 1);
|
||||||
editor.scrollTo(null, scrollInfo.top);
|
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) {
|
editor.on('focus', function (cm) {
|
||||||
for (var i = 0; i < onlineUsers.length; i++) {
|
for (var i = 0; i < onlineUsers.length; i++) {
|
||||||
|
|
Loading…
Reference in a new issue