Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Indent guides on sequences of blank lines are affected by the content of
// adjacent lines.
if (this.showIndentGuides) {
while (startRow > 0) {
if (this.buffer.lineLengthForRow(startRow - 1) > 0) break
startRow--
}
while (newEndRow < this.buffer.getLastRow()) {
if (this.buffer.lineLengthForRow(newEndRow + 1) > 0) break
oldEndRow++
newEndRow++
}
}
const combinedChanges = new Patch()
this.indexedBufferRowCount += newEndRow - oldEndRow
const {start, oldExtent, newExtent} = this.updateSpatialIndex(startRow, oldEndRow + 1, newEndRow + 1, Infinity)
combinedChanges.splice(start, oldExtent, newExtent)
for (let bufferRange of this.textDecorationLayer.getInvalidatedRanges()) {
bufferRange = Range.fromObject(bufferRange)
this.populateSpatialIndexIfNeeded(bufferRange.end.row + 1, Infinity)
const startBufferRow = this.findBoundaryPrecedingBufferRow(bufferRange.start.row)
const endBufferRow = this.findBoundaryFollowingBufferRow(bufferRange.end.row + 1)
const startRow = this.translateBufferPositionWithSpatialIndex(Point(startBufferRow, 0), 'backward').row
const endRow = this.translateBufferPositionWithSpatialIndex(Point(endBufferRow, 0), 'backward').row
const extent = Point(endRow - startRow, 0)
spliceArray(this.cachedScreenLines, startRow, extent.row, new Array(extent.row))
combinedChanges.splice(Point(startRow, 0), extent, extent)
}
exports.patchFromChanges = function (changes) {
const patch = new Patch()
for (let i = 0; i < changes.length; i++) {
const {oldStart, oldEnd, oldText, newStart, newEnd, newText} = changes[i]
const oldExtent = traversal(oldEnd, oldStart)
const newExtent = traversal(newEnd, newStart)
patch.splice(newStart, oldExtent, newExtent, oldText, newText)
}
return patch
}
this.foldsMarkerLayer = params.foldsMarkerLayer || buffer.addMarkerLayer({
maintainHistory: false,
persistent: true,
destroyInvalidatedMarkers: true
})
this.foldIdCounter = params.foldIdCounter || 1
if (params.spatialIndex) {
this.spatialIndex = params.spatialIndex
this.tabCounts = params.tabCounts
this.screenLineLengths = params.screenLineLengths
this.rightmostScreenPosition = params.rightmostScreenPosition
this.indexedBufferRowCount = params.indexedBufferRowCount
} else {
this.spatialIndex = new Patch({mergeAdjacentHunks: false})
this.tabCounts = []
this.screenLineLengths = []
this.rightmostScreenPosition = Point(0, 0)
this.indexedBufferRowCount = 0
}
}