mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
🔥 Use just isFoldableAtBufferRow
This commit is contained in:
@@ -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) ->
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) ->
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -33,7 +33,6 @@ class TokenizedLine
|
||||
endOfLineInvisibles: null
|
||||
lineIsWhitespaceOnly: false
|
||||
firstNonWhitespaceIndex: 0
|
||||
foldable: false
|
||||
|
||||
constructor: (properties) ->
|
||||
@id = idCounter++
|
||||
|
||||
Reference in New Issue
Block a user