Don't change number of tiles based on block decorations

This means we may render more tiles than necessary when we have block
decorations, but it prevents changing the number of rendered tiles
during scrolling with certain combinations of line height and editor
height. If it ever becomes a problem we can get smarter about
subtracting the height of the visible block decorations from the editor
height, but for now this gives us more reliable performance for the
common case.
This commit is contained in:
Nathan Sobo
2017-05-09 15:09:14 -06:00
parent f2aba0afc2
commit 4eecf8d1a6
2 changed files with 43 additions and 39 deletions

View File

@@ -2553,12 +2553,16 @@ class TextEditorComponent {
return this.derivedDimensionsCache.lastVisibleRow
}
// We may render more tiles than needed if some contain block decorations,
// but keeping this calculation simple ensures the number of tiles remains
// fixed for a given editor height, which eliminates situations where a
// tile is repeatedly added and removed during scrolling in certain
// comibinations of editor height and line height.
getVisibleTileCount () {
if (this.derivedDimensionsCache.visibleTileCount == null) {
const visibleRowCount = this.getLastVisibleRow() - this.getFirstVisibleRow()
this.derivedDimensionsCache.visibleTileCount = Math.ceil(visibleRowCount / this.getRowsPerTile()) + 1
const editorHeightInTiles = this.getScrollContainerHeight() / this.getLineHeight() / this.getRowsPerTile()
this.derivedDimensionsCache.visibleTileCount = Math.ceil(editorHeightInTiles) + 1
}
return this.derivedDimensionsCache.visibleTileCount
}