Skip to content

Commit d90acf8

Browse files
committed
Update and fix editor might not sync scrolling from edit mode to both mode
1 parent e9b0ce8 commit d90acf8

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

public/js/index.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -721,15 +721,17 @@ function windowResizeInner(callback) {
721721
//refresh editor
722722
if (loaded) {
723723
if (editor.getOption('scrollbarStyle') === 'native') {
724-
clearMap();
725-
if (editorHasFocus()) {
726-
syncScrollToView();
727-
} else {
728-
syncScrollToEdit();
729-
}
730-
updateScrollspy();
731-
if (callback && typeof callback === 'function')
732-
callback();
724+
setTimeout(function () {
725+
clearMap();
726+
if (editorHasFocus()) {
727+
syncScrollToView();
728+
} else {
729+
syncScrollToEdit();
730+
}
731+
updateScrollspy();
732+
if (callback && typeof callback === 'function')
733+
callback();
734+
}, 1);
733735
} else {
734736
// force it load all docs at once to prevent scroll knob blink
735737
editor.setOption('viewportMargin', Infinity);
@@ -1030,6 +1032,11 @@ function changeMode(type) {
10301032
preventSyncScrollToEdit = 2;
10311033
syncScrollToView();
10321034
}
1035+
1036+
if (lastMode == modeType.both && currentMode != modeType.both) {
1037+
preventSyncScrollToView = false;
1038+
preventSyncScrollToEdit = false;
1039+
}
10331040

10341041
if (lastMode != modeType.edit && currentMode == modeType.edit) {
10351042
editor.refresh();

public/js/syncscroll.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,7 @@ var viewScrollingDebounce = 200;
120120
var editScrolling = false;
121121
var editScrollingDebounce = 200;
122122

123-
if (editor.getOption('scrollbarStyle') === 'native') {
124-
ui.area.codemirrorScroll.on('scroll', _.throttle(syncScrollToView, editScrollThrottle));
125-
} else {
126-
editor.on('scroll', _.throttle(syncScrollToView, editScrollThrottle));
127-
}
123+
ui.area.codemirrorScroll.on('scroll', _.throttle(syncScrollToView, editScrollThrottle));
128124
ui.area.view.on('scroll', _.throttle(syncScrollToEdit, viewScrollThrottle));
129125

130126
var scrollMap, lineHeightMap, viewTop, viewBottom;

0 commit comments

Comments
 (0)