Skip to content

Commit c62b0b1

Browse files
committed
fix regression in ace_popup
1 parent 79eda6d commit c62b0b1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/ace/virtual_renderer.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -816,10 +816,15 @@ var VirtualRenderer = function(container, theme) {
816816
// lines may have been pushed down. If so, the first screen row will not
817817
// have changed, but the first actual row will. In that case, adjust
818818
// scrollTop so that the cursor and onscreen content stays in the same place.
819+
// TODO: find a better way to handle this, that works non wrapped case and doesn't compute layerConfig twice
819820
if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) {
820-
this.scrollTop = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
821-
changes = changes | this.CHANGE_SCROLL;
822-
changes |= this.$computeLayerConfig();
821+
var st = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
822+
if (st > 0) {
823+
// this check is needed as a workaround for the documentToScreenRow returning -1 if document.length == 0
824+
this.scrollTop = st;
825+
changes = changes | this.CHANGE_SCROLL;
826+
changes |= this.$computeLayerConfig();
827+
}
823828
}
824829
config = this.layerConfig;
825830
// update scrollbar first to not lose scroll position when gutter calls resize

0 commit comments

Comments
 (0)