Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Commit 798a051

Browse files
redmundsmarijnh
authored andcommitted
add gutter filler
1 parent 5dbe952 commit 798a051

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

lib/codemirror.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
padding: 0 4px; /* Horizontal padding of content */
2020
}
2121

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

@@ -125,7 +125,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
125125
/* The fake, visible scrollbars. Used to force redraw during scrolling
126126
before actuall scrolling happens, thus preventing shaking and
127127
flickering artifacts. */
128-
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler {
128+
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
129129
position: absolute;
130130
z-index: 6;
131131
display: none;
@@ -142,7 +142,9 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
142142
}
143143
.CodeMirror-scrollbar-filler {
144144
right: 0; bottom: 0;
145-
z-index: 6;
145+
}
146+
.CodeMirror-gutter-filler {
147+
left: 0; bottom: 0;
146148
}
147149

148150
.CodeMirror-gutters {

lib/codemirror.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ window.CodeMirror = (function() {
105105
d.scrollbarH = elt("div", [elt("div", null, null, "height: 1px")], "CodeMirror-hscrollbar");
106106
d.scrollbarV = elt("div", [elt("div", null, null, "width: 1px")], "CodeMirror-vscrollbar");
107107
d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
108+
d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
108109
// DIVs containing the selection and the actual code
109110
d.lineDiv = elt("div", null, "CodeMirror-code");
110111
d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
@@ -133,7 +134,7 @@ window.CodeMirror = (function() {
133134
d.scroller.setAttribute("tabIndex", "-1");
134135
// The element in which the editor lives.
135136
d.wrapper = elt("div", [d.inputDiv, d.scrollbarH, d.scrollbarV,
136-
d.scrollbarFiller, d.scroller], "CodeMirror");
137+
d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
137138
// Work around IE7 z-index bug
138139
if (ie_lt8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
139140
if (place.appendChild) place.appendChild(d.wrapper); else place(d.wrapper);
@@ -212,7 +213,7 @@ window.CodeMirror = (function() {
212213
estimateLineHeights(cm);
213214
regChange(cm);
214215
clearCaches(cm);
215-
setTimeout(function(){updateScrollbars(cm.display, cm.doc.height);}, 100);
216+
setTimeout(function(){updateScrollbars(cm.display, cm.doc.height, cm.options.fixedGutter);}, 100);
216217
}
217218

218219
function estimateHeight(cm) {
@@ -317,7 +318,7 @@ window.CodeMirror = (function() {
317318

318319
// Re-synchronize the fake scrollbars with the actual size of the
319320
// content. Optionally force a scrollTop.
320-
function updateScrollbars(d /* display */, docHeight) {
321+
function updateScrollbars(d /* display */, docHeight, fixedGutter) {
321322
var totalHeight = docHeight + paddingVert(d);
322323
d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + "px";
323324
var scrollHeight = Math.max(totalHeight, d.scroller.scrollHeight);
@@ -339,6 +340,11 @@ window.CodeMirror = (function() {
339340
d.scrollbarFiller.style.display = "block";
340341
d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = scrollbarWidth(d.measure) + "px";
341342
} else d.scrollbarFiller.style.display = "";
343+
if (needsH && fixedGutter) {
344+
d.gutterFiller.style.display = "block";
345+
d.gutterFiller.style.height = scrollbarWidth(d.measure) + "px";
346+
d.gutterFiller.style.width = d.gutters.offsetWidth + "px";
347+
} else d.gutterFiller.style.display = "";
342348

343349
if (mac_geLion && scrollbarWidth(d.measure) === 0)
344350
d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = mac_geMountainLion ? "18px" : "12px";
@@ -404,7 +410,7 @@ window.CodeMirror = (function() {
404410
signalLater(cm, "viewportChange", cm, cm.display.showingFrom, cm.display.showingTo);
405411
} else break;
406412
updateSelection(cm);
407-
updateScrollbars(cm.display, cm.doc.height);
413+
updateScrollbars(cm.display, cm.doc.height, cm.options.fixedGutter);
408414

409415
// Clip forced viewport to actual scrollable area
410416
if (viewPort)
@@ -1590,7 +1596,7 @@ window.CodeMirror = (function() {
15901596
var target = e_target(e);
15911597
if (target == display.scrollbarH || target == display.scrollbarH.firstChild ||
15921598
target == display.scrollbarV || target == display.scrollbarV.firstChild ||
1593-
target == display.scrollbarFiller) return null;
1599+
target == display.scrollbarFiller || target == display.gutterFiller) return null;
15941600
}
15951601
var x, y, space = getRect(display.lineSpace);
15961602
// Fails unpredictably on IE[67] when mouse is dragged around quickly.

0 commit comments

Comments
 (0)