Fixing bug in selection rendering which was misplaced since padding was not used.

This commit is contained in:
Irakli Gozalishvili 2011-07-20 12:08:45 +02:00
commit 2ed9c5d599

View file

@ -55,7 +55,6 @@ var Marker = function(parentEl) {
this.setPadding = function(padding) { this.setPadding = function(padding) {
this.$padding = padding; this.$padding = padding;
}; };
this.setSession = function(session) { this.setSession = function(session) {
this.session = session; this.session = session;
}; };
@ -131,7 +130,8 @@ var Marker = function(parentEl) {
var height = layerConfig.lineHeight; var height = layerConfig.lineHeight;
var width = Math.round(layerConfig.width - (range.start.column * layerConfig.characterWidth)); var width = Math.round(layerConfig.width - (range.start.column * layerConfig.characterWidth));
var top = this.$getTop(range.start.row, layerConfig); var top = this.$getTop(range.start.row, layerConfig);
var left = Math.round(range.start.column * layerConfig.characterWidth); var left = Math.round(this.$padding +
range.start.column * layerConfig.characterWidth);
stringBuilder.push( stringBuilder.push(
"<div class='", clazz, "' style='", "<div class='", clazz, "' style='",
@ -142,27 +142,30 @@ var Marker = function(parentEl) {
); );
// from start of the last line to the selection end // from start of the last line to the selection end
var top = this.$getTop(range.end.row, layerConfig); top = this.$getTop(range.end.row, layerConfig);
var width = Math.round(range.end.column * layerConfig.characterWidth); width = Math.round(range.end.column * layerConfig.characterWidth);
stringBuilder.push( stringBuilder.push(
"<div class='", clazz, "' style='", "<div class='", clazz, "' style='",
"height:", height, "px;", "height:", height, "px;",
"width:", width, "px;",
"top:", top, "px;", "top:", top, "px;",
"width:", width, "px;'></div>" "left:", left, "px;'></div>"
); );
// all the complete lines // all the complete lines
var height = (range.end.row - range.start.row - 1) * layerConfig.lineHeight; height = (range.end.row - range.start.row - 1) * layerConfig.lineHeight;
if (height < 0) if (height < 0)
return; return;
var top = this.$getTop(range.start.row + 1, layerConfig); top = this.$getTop(range.start.row + 1, layerConfig);
width = layerConfig.width;
stringBuilder.push( stringBuilder.push(
"<div class='", clazz, "' style='", "<div class='", clazz, "' style='",
"height:", height, "px;", "height:", height, "px;",
"width:", layerConfig.width, "px;", "width:", width, "px;",
"top:", top, "px;'></div>" "top:", top, "px;",
"left:", left, "px;'></div>"
); );
}; };