Skip to content

Commit 2f37f66

Browse files
committed
Properly restore horizonal scroll position on refresh() calls
Issue #1164
1 parent 180e752 commit 2f37f66

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/codemirror.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2829,8 +2829,11 @@ window.CodeMirror = (function() {
28292829

28302830
refresh: function() {
28312831
clearCaches(this);
2832-
if (this.display.scroller.scrollHeight > this.view.scrollTop)
2833-
this.display.scrollbarV.scrollTop = this.display.scroller.scrollTop = this.view.scrollTop;
2832+
var sTop = this.view.scrollTop, sLeft = this.view.scrollLeft;
2833+
if (this.display.scroller.scrollHeight > sTop)
2834+
this.display.scrollbarV.scrollTop = this.display.scroller.scrollTop = sTop;
2835+
if (this.display.scroller.scrollWidth > sLeft)
2836+
this.display.scrollbarH.scrollLeft = this.display.scroller.scrollLeft = sLeft;
28342837
updateDisplay(this, true);
28352838
},
28362839

0 commit comments

Comments
 (0)