mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user