Merge remote branch 'jpallen/master'
This commit is contained in:
commit
08a783d050
2 changed files with 17 additions and 1 deletions
|
|
@ -769,6 +769,9 @@ var Editor =function(renderer, session) {
|
|||
this.renderer.scrollToRow(row);
|
||||
};
|
||||
|
||||
this.scrollToLine = function(line, center) {
|
||||
this.renderer.scrollToLine(line, center);
|
||||
};
|
||||
|
||||
this.getCursorPosition = function() {
|
||||
return this.selection.getCursor();
|
||||
|
|
@ -806,7 +809,7 @@ var Editor =function(renderer, session) {
|
|||
this.$blockScrolling -= 1;
|
||||
|
||||
if (!this.isRowVisible(this.getCursorPosition().row)) {
|
||||
this.scrollToRow(lineNumber - 1 - Math.floor(this.getVisibleRowCount() / 2));
|
||||
this.scrollToLine(lineNumber, true);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -592,6 +592,19 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.scrollToY(row * this.lineHeight);
|
||||
};
|
||||
|
||||
this.scrollToLine = function(line, center) {
|
||||
var lineHeight = { lineHeight: this.lineHeight };
|
||||
var offset = 0;
|
||||
for (var l = 1; l < line; l++) {
|
||||
offset += this.session.getRowHeight(lineHeight, l-1);
|
||||
}
|
||||
|
||||
if (center) {
|
||||
offset -= this.$size.scrollerHeight / 2;
|
||||
}
|
||||
this.scrollToY(offset);
|
||||
};
|
||||
|
||||
this.scrollToY = function(scrollTop) {
|
||||
var maxHeight = this.session.getScreenLength() * this.lineHeight - this.$size.scrollerHeight;
|
||||
var scrollTop = Math.max(0, Math.min(maxHeight, scrollTop));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue