Skip to content

Commit 9d92920

Browse files
committed
Add coverGutterNextToScrollbar option
Issue #1493
1 parent 798a051 commit 9d92920

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

doc/manual.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ <h2 id="config">Configuration</h2>
232232
horizontally (false) or whether it stays fixed during horizontal
233233
scrolling (true, the default).</dd>
234234

235+
<dt id="option_coverGutterNextToScrollbar"><code><strong>coverGutterNextToScrollbar</strong>: boolean</code></dt>
236+
<dd>When <a href="#option_fixedGutter"><code>fixedGutter</code></a>
237+
is on, and there is a horizontal scrollbar, by default the
238+
gutter will be visible to the left of this scrollbar. If this
239+
option is set to true, it will be covered by an element with
240+
class <code>CodeMirror-gutter-filler</code>.</dd>
241+
235242
<dt id="option_readOnly"><code><strong>readOnly</strong>: boolean|string</code></dt>
236243
<dd>This disables editing of the editor content by the user. If
237244
the special value <code>"nocursor"</code> is given (instead of

lib/codemirror.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ window.CodeMirror = (function() {
213213
estimateLineHeights(cm);
214214
regChange(cm);
215215
clearCaches(cm);
216-
setTimeout(function(){updateScrollbars(cm.display, cm.doc.height, cm.options.fixedGutter);}, 100);
216+
setTimeout(function(){updateScrollbars(cm);}, 100);
217217
}
218218

219219
function estimateHeight(cm) {
@@ -251,6 +251,7 @@ window.CodeMirror = (function() {
251251

252252
function guttersChanged(cm) {
253253
updateGutters(cm);
254+
alignHorizontally(cm);
254255
regChange(cm);
255256
}
256257

@@ -318,7 +319,8 @@ window.CodeMirror = (function() {
318319

319320
// Re-synchronize the fake scrollbars with the actual size of the
320321
// content. Optionally force a scrollTop.
321-
function updateScrollbars(d /* display */, docHeight, fixedGutter) {
322+
function updateScrollbars(cm) {
323+
var d = cm.display, docHeight = cm.doc.height;
322324
var totalHeight = docHeight + paddingVert(d);
323325
d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + "px";
324326
var scrollHeight = Math.max(totalHeight, d.scroller.scrollHeight);
@@ -340,7 +342,7 @@ window.CodeMirror = (function() {
340342
d.scrollbarFiller.style.display = "block";
341343
d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = scrollbarWidth(d.measure) + "px";
342344
} else d.scrollbarFiller.style.display = "";
343-
if (needsH && fixedGutter) {
345+
if (needsH && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
344346
d.gutterFiller.style.display = "block";
345347
d.gutterFiller.style.height = scrollbarWidth(d.measure) + "px";
346348
d.gutterFiller.style.width = d.gutters.offsetWidth + "px";
@@ -410,7 +412,7 @@ window.CodeMirror = (function() {
410412
signalLater(cm, "viewportChange", cm, cm.display.showingFrom, cm.display.showingTo);
411413
} else break;
412414
updateSelection(cm);
413-
updateScrollbars(cm.display, cm.doc.height, cm.options.fixedGutter);
415+
updateScrollbars(cm);
414416

415417
// Clip forced viewport to actual scrollable area
416418
if (viewPort)
@@ -3123,6 +3125,7 @@ window.CodeMirror = (function() {
31233125
cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
31243126
cm.refresh();
31253127
}, true);
3128+
option("coverGutterNextToScrollbar", false, updateScrollbars);
31263129
option("lineNumbers", false, function(cm) {
31273130
setGuttersForLineNumbers(cm.options);
31283131
guttersChanged(cm);

0 commit comments

Comments
 (0)