🔥 Use just isFoldableAtBufferRow

This commit is contained in:
Antonio Scandurra
2016-02-17 15:05:31 +01:00
parent 90c75fd6da
commit bea324eae9
7 changed files with 47 additions and 75 deletions

View File

@@ -413,8 +413,8 @@ class DisplayBuffer extends Model
isFoldedAtScreenRow: (screenRow) ->
@largestFoldContainingBufferRow(@bufferRowForScreenRow(screenRow))?
foldableBufferRowsForBufferRowRange: (startRow, endRow) ->
@tokenizedBuffer.foldableRowsForRowRange(startRow, endRow)
isFoldableAtBufferRow: (row) ->
@tokenizedBuffer.isFoldableAtRow(row)
# Destroys the fold with the given id
destroyFoldWithId: (id) ->

View File

@@ -600,8 +600,14 @@ class TextEditorPresenter
if endRow > startRow
bufferRows = @model.bufferRowsForScreenRows(startRow, endRow - 1)
foldableBufferRows = @model.foldableBufferRowsForBufferRowRange(bufferRows[0], bufferRows[bufferRows.length - 1])
previousBufferRow = -1
foldable = false
for bufferRow, i in bufferRows
# don't compute foldability more than once per buffer row
if previousBufferRow isnt bufferRow
foldable = @model.isFoldableAtBufferRow(bufferRow)
previousBufferRow = bufferRow
if bufferRow is lastBufferRow
softWrapped = true
else
@@ -611,7 +617,6 @@ class TextEditorPresenter
screenRow = startRow + i
line = @model.tokenizedLineForScreenRow(screenRow)
decorationClasses = @lineNumberDecorationClassesForRow(screenRow)
foldable = foldableBufferRows.has(bufferRow)
blockDecorationsBeforeCurrentScreenRowHeight = @lineTopIndex.pixelPositionAfterBlocksForRow(screenRow) - @lineTopIndex.pixelPositionBeforeBlocksForRow(screenRow)
blockDecorationsHeight = blockDecorationsBeforeCurrentScreenRowHeight
if screenRow % @tileSize isnt 0

View File

@@ -2939,8 +2939,7 @@ class TextEditor extends Model
#
# Returns a {Boolean}.
isFoldableAtBufferRow: (bufferRow) ->
# @languageMode.isFoldableAtBufferRow(bufferRow)
@foldableBufferRowsForBufferRowRange(bufferRow, bufferRow).has(bufferRow)
@displayBuffer.isFoldableAtBufferRow(bufferRow)
# Extended: Determine whether the given row in screen coordinates is foldable.
#
@@ -2953,9 +2952,6 @@ class TextEditor extends Model
bufferRow = @displayBuffer.bufferRowForScreenRow(screenRow)
@isFoldableAtBufferRow(bufferRow)
foldableBufferRowsForBufferRowRange: (startRow, endRow) ->
@displayBuffer.foldableBufferRowsForBufferRowRange(startRow, endRow)
# Extended: Fold the given buffer row if it isn't currently folded, and unfold
# it otherwise.
toggleFoldAtBufferRow: (bufferRow) ->

View File

@@ -282,15 +282,6 @@ class TokenizedBuffer extends Model
row - increment
foldableRowsForRowRange: (startRow, endRow) ->
scanStartRow = @buffer.previousNonBlankRow(startRow) ? startRow
scanStartRow-- while scanStartRow > 0 and @tokenizedLineForRow(scanStartRow).isComment()
scanEndRow = @buffer.nextNonBlankRow(endRow) ? endRow
foldableRows = new Set
for row in [scanStartRow..scanEndRow] by 1 when @isFoldableAtRow(row)
foldableRows.add(row)
foldableRows
isFoldableAtRow: (row) ->
if @largeFileMode
false

View File

@@ -33,7 +33,6 @@ class TokenizedLine
endOfLineInvisibles: null
lineIsWhitespaceOnly: false
firstNonWhitespaceIndex: 0
foldable: false
constructor: (properties) ->
@id = idCounter++