find and undo must center selection into view

This commit is contained in:
nightwing 2012-04-26 10:12:19 +04:00
commit 621c7c3dc8
2 changed files with 18 additions and 12 deletions

View file

@ -678,13 +678,13 @@ var VirtualRenderer = function(container, theme) {
this.$cursorLayer.showCursor();
};
this.scrollSelectionIntoView = function(anchor, lead) {
this.scrollSelectionIntoView = function(anchor, lead, offset) {
// first scroll anchor into view then scroll lead into view
this.scrollCursorIntoView(anchor);
this.scrollCursorIntoView(lead);
this.scrollCursorIntoView(anchor, offset);
this.scrollCursorIntoView(lead, offset);
};
this.scrollCursorIntoView = function(cursor) {
this.scrollCursorIntoView = function(cursor, offset) {
// the editor is not visible
if (this.$size.scrollerHeight === 0)
return;
@ -695,10 +695,12 @@ var VirtualRenderer = function(container, theme) {
var top = pos.top;
if (this.scrollTop > top) {
if (offset)
top -= offset * this.$size.scrollerHeight;
this.session.setScrollTop(top);
}
if (this.scrollTop + this.$size.scrollerHeight < top + this.lineHeight) {
} else if (this.scrollTop + this.$size.scrollerHeight < top + this.lineHeight) {
if (offset)
top += offset * this.$size.scrollerHeight;
this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
}
@ -708,9 +710,7 @@ var VirtualRenderer = function(container, theme) {
if (left < this.$padding + 2 * this.layerConfig.characterWidth)
left = 0;
this.session.setScrollLeft(left);
}
if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
} else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
}
};