fix gutter is too short when hor scrollbar is visible

This commit is contained in:
nightwing 2014-01-30 21:43:53 +04:00
commit eafe6a7997
2 changed files with 15 additions and 13 deletions

View file

@ -118,9 +118,9 @@ var Gutter = function(parentEl) {
};
this.update = function(config) {
var firstRow = config.firstRow;
var lastRow = config.lastRow;
var session = this.session;
var firstRow = config.firstRow;
var lastRow = Math.min(config.lastRow + 1, session.getLength() - 1); // needed to compensate
var fold = session.getNextFoldLine(firstRow);
var foldStart = fold ? fold.start.row : Infinity;
var foldWidgets = this.$showFoldWidgets && session.foldWidgets;

View file

@ -894,18 +894,19 @@ var VirtualRenderer = function(container, theme) {
this.$autosize();
var session = this.session;
var size = this.$size;
var hideScrollbars = this.$size.height <= 2 * this.lineHeight;
var hideScrollbars = size.height <= 2 * this.lineHeight;
var screenLines = this.session.getScreenLength();
var maxHeight = screenLines * this.lineHeight;
var offset = this.scrollTop % this.lineHeight;
var minHeight = this.$size.scrollerHeight + this.lineHeight;
var minHeight = size.scrollerHeight + this.lineHeight;
var longestLine = this.$getLongestLine();
var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
this.$size.scrollerWidth - longestLine - 2 * this.$padding < 0);
size.scrollerWidth - longestLine - 2 * this.$padding < 0);
var hScrollChanged = this.$horizScroll !== horizScroll;
if (hScrollChanged) {
@ -914,15 +915,15 @@ var VirtualRenderer = function(container, theme) {
}
if (!this.$maxLines && this.$scrollPastEnd) {
if (this.scrollTop > maxHeight - this.$size.scrollerHeight)
if (this.scrollTop > maxHeight - size.scrollerHeight)
maxHeight += Math.min(
(this.$size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd,
this.scrollTop - maxHeight + this.$size.scrollerHeight
(size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd,
this.scrollTop - maxHeight + size.scrollerHeight
);
}
var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
this.$size.scrollerHeight - maxHeight < 0);
size.scrollerHeight - maxHeight < 0);
var vScrollChanged = this.$vScroll !== vScroll;
if (vScrollChanged) {
this.$vScroll = vScroll;
@ -930,10 +931,10 @@ var VirtualRenderer = function(container, theme) {
}
this.session.setScrollTop(Math.max(-this.scrollMargin.top,
Math.min(this.scrollTop, maxHeight - this.$size.scrollerHeight + this.scrollMargin.v)));
Math.min(this.scrollTop, maxHeight - size.scrollerHeight + this.scrollMargin.v)));
this.session.setScrollLeft(Math.max(-this.scrollMargin.left, Math.min(this.scrollLeft,
longestLine + 2 * this.$padding - this.$size.scrollerWidth + this.scrollMargin.h)));
longestLine + 2 * this.$padding - size.scrollerWidth + this.scrollMargin.h)));
var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
@ -955,7 +956,7 @@ var VirtualRenderer = function(container, theme) {
firstRowHeight = session.getRowLength(firstRow) * lineHeight;
lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1);
minHeight = this.$size.scrollerHeight + session.getRowLength(lastRow) * lineHeight +
minHeight = size.scrollerHeight + session.getRowLength(lastRow) * lineHeight +
firstRowHeight;
offset = this.scrollTop - firstRowScreen * lineHeight;
@ -964,7 +965,7 @@ var VirtualRenderer = function(container, theme) {
// Horizontal scrollbar visibility may have changed, which changes
// the client height of the scroller
if (hScrollChanged || vScrollChanged) {
changes = this.$updateCachedSize(true, this.gutterWidth, this.$size.width, this.$size.height);
changes = this.$updateCachedSize(true, this.gutterWidth, size.width, size.height);
this._signal("scrollbarVisibilityChanged");
if (vScrollChanged)
longestLine = this.$getLongestLine();
@ -981,6 +982,7 @@ var VirtualRenderer = function(container, theme) {
minHeight : minHeight,
maxHeight : maxHeight,
offset : offset,
gutterOffset : Math.ceil((offset + size.height - size.scrollerHeight) / lineHeight),
height : this.$size.scrollerHeight
};