From afa6c9a786512561295600cc8bea244c6355de0b Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 9 Jul 2015 01:20:04 -0500 Subject: [PATCH] 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? --- src/display-buffer.coffee | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/display-buffer.coffee b/src/display-buffer.coffee index d7dc236d6..6d3f47bea 100644 --- a/src/display-buffer.coffee +++ b/src/display-buffer.coffee @@ -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