fix scrollToLine for sessions containing folds
This commit is contained in:
parent
57bb9f767c
commit
35aecf42af
3 changed files with 9 additions and 13 deletions
|
|
@ -1205,8 +1205,7 @@ var Editor = function(renderer, session) {
|
|||
var range = this.$search.find(this.session);
|
||||
if (range) {
|
||||
this.session.unfold(range);
|
||||
this.gotoLine(range.end.row+1, range.end.column);
|
||||
this.selection.setSelectionRange(range);
|
||||
this.selection.setSelectionRange(range); // this scrolls selection into view
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ var Cursor = function(parentEl) {
|
|||
}, 1000);
|
||||
};
|
||||
|
||||
this.getPixelPosition = function(onScreen) {
|
||||
this.getPixelPosition = function(position, onScreen) {
|
||||
if (!this.config || !this.session) {
|
||||
return {
|
||||
left : 0,
|
||||
|
|
@ -101,7 +101,8 @@ var Cursor = function(parentEl) {
|
|||
};
|
||||
}
|
||||
|
||||
var position = this.session.selection.getCursor();
|
||||
if (!position)
|
||||
position = this.session.selection.getCursor();
|
||||
var pos = this.session.documentToScreenPosition(position);
|
||||
var cursorLeft = Math.round(this.$padding +
|
||||
pos.column * this.config.characterWidth);
|
||||
|
|
@ -117,7 +118,7 @@ var Cursor = function(parentEl) {
|
|||
this.update = function(config) {
|
||||
this.config = config;
|
||||
|
||||
this.pixelPos = this.getPixelPosition(true);
|
||||
this.pixelPos = this.getPixelPosition(null, true);
|
||||
|
||||
this.cursor.style.left = this.pixelPos.left + "px";
|
||||
this.cursor.style.top = this.pixelPos.top + "px";
|
||||
|
|
|
|||
|
|
@ -685,15 +685,11 @@ var VirtualRenderer = function(container, theme) {
|
|||
};
|
||||
|
||||
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) {
|
||||
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
|
||||
var offset = pos.top;
|
||||
if (center)
|
||||
offset -= this.$size.scrollerHeight / 2;
|
||||
}
|
||||
|
||||
this.session.setScrollTop(offset);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue