Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/codemirror.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
padding: 0 4px; /* Horizontal padding of content */
}

.CodeMirror-scrollbar-filler {
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white; /* The little square between H and V scrollbars */
}

Expand Down Expand Up @@ -124,7 +124,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
/* The fake, visible scrollbars. Used to force redraw during scrolling
before actuall scrolling happens, thus preventing shaking and
flickering artifacts. */
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler {
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
position: absolute;
z-index: 6;
display: none;
Expand All @@ -141,7 +141,9 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
}
.CodeMirror-scrollbar-filler {
right: 0; bottom: 0;
z-index: 6;
}
.CodeMirror-gutter-filler {
left: 0; bottom: 0;
}

.CodeMirror-gutters {
Expand Down
16 changes: 11 additions & 5 deletions lib/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ window.CodeMirror = (function() {
d.scrollbarH = elt("div", [elt("div", null, null, "height: 1px")], "CodeMirror-hscrollbar");
d.scrollbarV = elt("div", [elt("div", null, null, "width: 1px")], "CodeMirror-vscrollbar");
d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
// DIVs containing the selection and the actual code
d.lineDiv = elt("div");
d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
Expand Down Expand Up @@ -133,7 +134,7 @@ window.CodeMirror = (function() {
d.scroller.setAttribute("tabIndex", "-1");
// The element in which the editor lives.
d.wrapper = elt("div", [d.inputDiv, d.scrollbarH, d.scrollbarV,
d.scrollbarFiller, d.scroller], "CodeMirror");
d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
// Work around IE7 z-index bug
if (ie_lt8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
if (place.appendChild) place.appendChild(d.wrapper); else place(d.wrapper);
Expand Down Expand Up @@ -214,7 +215,7 @@ window.CodeMirror = (function() {
estimateLineHeights(cm);
regChange(cm);
clearCaches(cm);
setTimeout(function(){updateScrollbars(cm.display, cm.doc.height);}, 100);
setTimeout(function(){updateScrollbars(cm.display, cm.doc.height, cm.options.fixedGutter);}, 100);
}

function estimateHeight(cm) {
Expand Down Expand Up @@ -319,7 +320,7 @@ window.CodeMirror = (function() {

// Re-synchronize the fake scrollbars with the actual size of the
// content. Optionally force a scrollTop.
function updateScrollbars(d /* display */, docHeight) {
function updateScrollbars(d /* display */, docHeight, fixedGutter) {
var totalHeight = docHeight + paddingVert(d);
d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + "px";
var scrollHeight = Math.max(totalHeight, d.scroller.scrollHeight);
Expand All @@ -341,6 +342,11 @@ window.CodeMirror = (function() {
d.scrollbarFiller.style.display = "block";
d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = scrollbarWidth(d.measure) + "px";
} else d.scrollbarFiller.style.display = "";
if (needsH && fixedGutter) {
d.gutterFiller.style.display = "block";
d.gutterFiller.style.height = scrollbarWidth(d.measure) + "px";
d.gutterFiller.style.width = d.gutters.offsetWidth + "px";
} else d.gutterFiller.style.display = "";

if (mac_geLion && scrollbarWidth(d.measure) === 0)
d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = mac_geMountainLion ? "18px" : "12px";
Expand Down Expand Up @@ -406,7 +412,7 @@ window.CodeMirror = (function() {
signalLater(cm, "viewportChange", cm, cm.display.showingFrom, cm.display.showingTo);
} else break;
updateSelection(cm);
updateScrollbars(cm.display, cm.doc.height);
updateScrollbars(cm.display, cm.doc.height, cm.options.fixedGutter);

// Clip forced viewport to actual scrollable area
if (viewPort)
Expand Down Expand Up @@ -1585,7 +1591,7 @@ window.CodeMirror = (function() {
var target = e_target(e);
if (target == display.scrollbarH || target == display.scrollbarH.firstChild ||
target == display.scrollbarV || target == display.scrollbarV.firstChild ||
target == display.scrollbarFiller) return null;
target == display.scrollbarFiller || target == display.gutterFiller) return null;
}
var x, y, space = getRect(display.lineSpace);
// Fails unpredictably on IE[67] when mouse is dragged around quickly.
Expand Down