Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #208 from atom/ns-mb-investigate-exceptions
Browse files Browse the repository at this point in the history
Verify valid state after updating spatial index
  • Loading branch information
Max Brunsfeld committed Feb 14, 2017
2 parents c6985ef + 2cde398 commit ed6af15
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/display-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,14 @@ class DisplayLayer {
screenPosition = this.collapseHardTabs(screenPosition, tabCount, clipDirection)
}
const bufferPosition = this.translateScreenPositionWithSpatialIndex(screenPosition, clipDirection, skipSoftWrapIndentation)

if (global.atom && bufferPosition.row >= this.buffer.getLineCount()) {
global.atom.assert(false, 'Invalid translated buffer row', {
bufferPosition, bufferLineCount: this.buffer.getLineCount()
})
return this.buffer.getEndPosition()
}

const columnDelta = this.getClipColumnDelta(bufferPosition, clipDirection)
if (columnDelta !== 0) {
return Point(bufferPosition.row, bufferPosition.column + columnDelta)
Expand Down Expand Up @@ -956,6 +964,18 @@ class DisplayLayer {
new Array(insertedScreenLineLengths.length)
)

if (global.atom && this.indexedBufferRowCount === this.buffer.getLineCount()) {
const lastScreenRow = this.getLastScreenRow()
const lastScreenColumn = this.lineLengthForScreenRow(lastScreenRow)
const translatedEndPosition = this.translateScreenPosition(Point(lastScreenRow, lastScreenColumn))
const expectedEndPosition = this.buffer.getEndPosition()
if (!translatedEndPosition.isEqual(expectedEndPosition)) {
global.atom.assert(false, 'Invalid spatial index state', {
lastScreenRow, lastScreenColumn, translatedEndPosition, expectedEndPosition
})
}
}

return {
start: Point(startScreenRow, 0),
oldExtent: Point(oldScreenRowCount, 0),
Expand Down

0 comments on commit ed6af15

Please sign in to comment.