Keep apparent scroll position fixed when changes are made offscreen

This commit is contained in:
James Allen 2014-08-06 13:10:41 +01:00
commit 146d832e19

View file

@ -809,6 +809,15 @@ var VirtualRenderer = function(container, theme) {
changes & this.CHANGE_H_SCROLL
) {
changes |= this.$computeLayerConfig();
// If a change is made offscreen and wrapMode is on, then the onscreen
// lines may have been pushed down. If so, the first screen row will not
// have changed, but the first actual row will. In that case, adjust
// scrollTop so that the cursor and onscreen content stays in the same place.
if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) {
this.scrollTop = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
changes = changes | this.CHANGE_SCROLL;
changes |= this.$computeLayerConfig();
}
config = this.layerConfig;
// update scrollbar first to not lose scroll position when gutter calls resize
this.$updateScrollBarV();