Skip to content

Commit b347ea5

Browse files
committed
Workaround editor might have wrong doc height and wrong simple scroll bar knob position when editor height changed
1 parent b996f80 commit b347ea5

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

public/js/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,10 +786,18 @@ function checkEditorStyle() {
786786
if (scrollbarStyle == 'overlay' || currentMode == modeType.both) {
787787
ui.area.codemirrorScroll.css('height', desireHeight + 'px');
788788
ui.area.codemirrorScroll.css('min-height', '');
789+
// workaround simple scroll bar knob
790+
// will get wrong position when editor height changed
791+
var scrollInfo = editor.getScrollInfo();
792+
preventSyncScroll = true;
793+
editor.scrollTo(null, scrollInfo.top - 1);
794+
editor.scrollTo(null, scrollInfo.top);
789795
} else if (scrollbarStyle == 'native') {
790796
ui.area.codemirrorScroll.css('height', '');
791797
ui.area.codemirrorScroll.css('min-height', desireHeight + 'px');
792798
}
799+
// workaround editor will have wrong doc height when editor height changed
800+
editor.setSize(null, ui.area.edit.height());
793801
//make editor resizable
794802
ui.area.edit.resizable({
795803
handles: 'e',

0 commit comments

Comments
 (0)