fix gutter width calculation

This commit is contained in:
nightwing 2012-08-26 22:40:43 +04:00
commit 3e0351ca98

View file

@ -93,11 +93,11 @@ var Gutter = function(parentEl) {
rowInfo.text.push(annoText);
var type = annotation.type;
if (type == "error")
rowInfo.className = "ace_error";
else if (type == "warning" && rowInfo.className != "ace_error")
rowInfo.className = "ace_warning";
rowInfo.className = " ace_error";
else if (type == "warning" && rowInfo.className != " ace_error")
rowInfo.className = " ace_warning";
else if (type == "info" && (!rowInfo.className))
rowInfo.className = "ace_info";
rowInfo.className = " ace_info";
}
}
};
@ -112,6 +112,7 @@ var Gutter = function(parentEl) {
var foldWidgets = this.$showFoldWidgets && this.session.foldWidgets;
var breakpoints = this.session.$breakpoints;
var decorations = this.session.$decorations;
var lastLineNumber = 0;
while (true) {
if(i > foldStart) {
@ -127,7 +128,7 @@ var Gutter = function(parentEl) {
"<div class='ace_gutter-cell ",
breakpoints[i] || "", decorations[i] || "", annotation.className,
"' style='height:", this.session.getRowLength(i) * config.lineHeight, "px;'>",
i + 1
lastLineNumber = i + 1
);
if (foldWidgets) {
@ -152,13 +153,14 @@ var Gutter = function(parentEl) {
this.element.style.height = config.minHeight + "px";
if (this.session.$useWrapMode)
i = this.session.getLength();
lastLineNumber = this.session.getLength();
var gutterWidth = ("" + --i).length * config.characterWidth;
var gutterWidth = ("" + lastLineNumber).length * config.characterWidth;
var padding = this.$padding || this.$computePadding();
gutterWidth += padding.left + padding.right;
if (gutterWidth !== this.gutterWidth) {
this.gutterWidth = gutterWidth;
this.element.style.width = Math.ceil(this.gutterWidth) + "px";
this._emit("changeGutterWidth", gutterWidth);
}
};