Add invariant assertion about line count to see if we can find a bug

Does the line count ever get out of whack after an update, or is it
happening in some other way?
This commit is contained in:
Nathan Sobo
2015-07-09 01:20:04 -05:00
parent 028acbcae4
commit afa6c9a786

View File

@@ -1194,6 +1194,9 @@ class DisplayBuffer extends Model
screenDelta = screenLines.length - (endScreenRow - startScreenRow)
_.spliceWithArray(@screenLines, startScreenRow, endScreenRow - startScreenRow, screenLines, 10000)
@checkScreenLinesInvariant()
@rowMap.spliceRegions(startBufferRow, endBufferRow - startBufferRow, regions)
@findMaxLineLength(startScreenRow, endScreenRow, screenLines, screenDelta)
@@ -1313,6 +1316,20 @@ class DisplayBuffer extends Model
else
delete @overlayDecorationsById[decoration.id]
checkScreenLinesInvariant: ->
return if @isSoftWrapped()
return if _.size(@foldsByMarkerId) > 0
screenLinesCount = @screenLines.length
tokenizedLinesCount = @tokenizedBuffer.getLineCount()
bufferLinesCount = @buffer.getLineCount()
atom.assert screenLinesCount is tokenizedLinesCount, "Display buffer line count out of sync with tokenized buffer", (error) ->
error.metadata = {screenLinesCount, tokenizedLinesCount, bufferLinesCount}
atom.assert screenLinesCount is bufferLinesCount, "Display buffer line count out of sync with buffer", (error) ->
error.metadata = {screenLinesCount, tokenizedLinesCount, bufferLinesCount}
if Grim.includeDeprecatedAPIs
DisplayBuffer.properties
softWrapped: null