Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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