diff --git a/src/text-editor-component.js b/src/text-editor-component.js index 4be22d9b2..ce6efe21e 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -122,7 +122,6 @@ class TextEditorComponent { this.horizontalPositionsToMeasure.clear() if (this.pendingAutoscroll) this.autoscrollVertically() this.populateVisibleRowRange() - const longestLineToMeasure = this.checkForNewLongestLine() this.queryScreenLinesToRender() this.queryDecorationsToRender() this.scrollbarsVisible = !this.refreshScrollbarStyling @@ -130,7 +129,7 @@ class TextEditorComponent { etch.updateSync(this) this.measureHorizontalPositions() - if (longestLineToMeasure) this.measureLongestLineWidth(longestLineToMeasure) + this.measureLongestLineWidth() this.updateAbsolutePositionedDecorations() if (this.pendingAutoscroll) { this.autoscrollHorizontally() @@ -587,16 +586,25 @@ class TextEditorComponent { ) } - // This is easier to mock getPlatform () { return process.platform } queryScreenLinesToRender () { - this.renderedScreenLines = this.props.model.displayLayer.getScreenLines( + const {model} = this.props + + this.renderedScreenLines = model.displayLayer.getScreenLines( this.getRenderedStartRow(), this.getRenderedEndRow() ) + + const longestLineRow = model.getApproximateLongestScreenRow() + const longestLine = model.screenLineForScreenRow(longestLineRow) + if (longestLine !== this.previousLongestLine) { + this.longestLineToMeasure = longestLine + this.longestLineToMeasureRow = longestLineRow + this.previousLongestLine = longestLine + } } renderedScreenLineForRow (row) { @@ -1409,24 +1417,14 @@ class TextEditorComponent { this.measurements.horizontalScrollbarHeight = this.refs.horizontalScrollbar.getRealScrollbarHeight() } - checkForNewLongestLine () { - const {model} = this.props - const longestLineRow = model.getApproximateLongestScreenRow() - const longestLine = model.screenLineForScreenRow(longestLineRow) - if (longestLine !== this.previousLongestLine) { - this.longestLineToMeasure = longestLine - this.longestLineToMeasureRow = longestLineRow - this.previousLongestLine = longestLine - return longestLine + measureLongestLineWidth () { + if (this.longestLineToMeasure) { + this.measurements.longestLineWidth = this.lineNodesByScreenLineId.get(this.longestLineToMeasure.id).firstChild.offsetWidth + this.longestLineToMeasureRow = null + this.longestLineToMeasure = null } } - measureLongestLineWidth (screenLine) { - this.measurements.longestLineWidth = this.lineNodesByScreenLineId.get(screenLine.id).firstChild.offsetWidth - this.longestLineToMeasureRow = null - this.longestLineToMeasure = null - } - requestHorizontalMeasurement (row, column) { if (column === 0) return let columns = this.horizontalPositionsToMeasure.get(row)