Fix rendering artifacts when resizing with soft wraps

Previously, we were accidentally depending on the state of the display
layer when forcing it to update its index. This caused us to not index
enough content to cover the visibile area, which meant we weren't
querying enough lines to fill the screen in some situations.
This commit is contained in:
Nathan Sobo
2017-05-08 10:58:33 -06:00
parent ecef2af271
commit f76e850aa5
2 changed files with 16 additions and 3 deletions

View File

@@ -457,6 +457,17 @@ describe('TextEditorComponent', () => {
expect(editor.lineLengthForScreenRow(0)).toBe(20)
})
it('correctly forces the display layer to index visible rows when resizing (regression)', async () => {
const text = 'a'.repeat(30) + '\n' + 'b'.repeat(1000)
const {component, element, editor} = buildComponent({height: 300, width: 800, attach: false, text})
editor.setSoftWrapped(true)
jasmine.attachToDOM(element)
element.style.width = 200 + 'px'
await component.getNextUpdatePromise()
expect(element.querySelectorAll('.line:not(.dummy)').length).toBe(24)
})
it('decorates the line numbers of folded lines', async () => {
const {component, element, editor} = buildComponent()
editor.foldBufferRow(1)

View File

@@ -236,7 +236,6 @@ class TextEditorComponent {
this.measureBlockDecorations()
this.measuredContent = false
this.updateModelSoftWrapColumn()
this.updateSyncBeforeMeasuringContent()
if (useScheduler === true) {
const scheduler = etch.getScheduler()
@@ -321,6 +320,7 @@ class TextEditorComponent {
updateSyncBeforeMeasuringContent () {
this.derivedDimensionsCache = {}
this.updateModelSoftWrapColumn()
if (this.pendingAutoscroll) {
const {screenRange, options} = this.pendingAutoscroll
this.autoscrollVertically(screenRange, options)
@@ -2668,8 +2668,10 @@ class TextEditorComponent {
// Ensure the spatial index is populated with rows that are currently
// visible so we *at least* get the longest row in the visible range.
populateVisibleRowRange () {
const endRow = this.getRenderedStartRow() + this.getVisibleTileCount() * this.getRowsPerTile()
this.props.model.displayLayer.populateSpatialIndexIfNeeded(Infinity, endRow)
const lastPossibleVisibleRow = this.rowForPixelPosition(this.getScrollBottom())
const maxPossibleVisibleTileCount = Math.floor((lastPossibleVisibleRow - this.getFirstVisibleRow()) / this.getRowsPerTile()) + 2
const lastPossibleRenderedRow = this.getRenderedStartRow() + maxPossibleVisibleTileCount * this.getRowsPerTile()
this.props.model.displayLayer.populateSpatialIndexIfNeeded(Infinity, lastPossibleRenderedRow)
}
getNextUpdatePromise () {