mirror of
https://github.com/atom/atom.git
synced 2026-02-07 05:05:02 -05:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user