Skip to content

Commit

Permalink
Explicitly set gutter height
Browse files Browse the repository at this point in the history
This prevents it from being repainted whenever the height of the inner
editor briefly changes during a repaint. (At least, it does on Webkit).

Issue #1514
  • Loading branch information
marijnh committed May 13, 2013
1 parent db76cee commit b2c1d96
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/codemirror.css
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}

.CodeMirror-gutters {
position: absolute; left: 0; top: 0;
height: 100%;
padding-bottom: 30px;
z-index: 3;
}
Expand Down
5 changes: 2 additions & 3 deletions lib/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,8 @@ window.CodeMirror = (function() {
// Will contain the gutters, if any
d.gutters = elt("div", null, "CodeMirror-gutters");
d.lineGutter = null;
// Helper element to properly size the gutter backgrounds
var scrollerInner = elt("div", [d.sizer, d.heightForcer, d.gutters], null, "position: relative; min-height: 100%");
// Provides scrolling
d.scroller = elt("div", [scrollerInner], "CodeMirror-scroll");
d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
d.scroller.setAttribute("tabIndex", "-1");
// The element in which the editor lives.
d.wrapper = elt("div", [d.inputDiv, d.scrollbarH, d.scrollbarV,
Expand Down Expand Up @@ -323,6 +321,7 @@ window.CodeMirror = (function() {
var d = cm.display, docHeight = cm.doc.height;
var totalHeight = docHeight + paddingVert(d);
d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + "px";
d.gutters.style.height = Math.max(totalHeight, d.scroller.clientHeight - scrollerCutOff) + "px";
var scrollHeight = Math.max(totalHeight, d.scroller.scrollHeight);
var needsH = d.scroller.scrollWidth > d.scroller.clientWidth;
var needsV = scrollHeight > d.scroller.clientHeight;
Expand Down

0 comments on commit b2c1d96

Please sign in to comment.