mirror of
https://github.com/atom/atom.git
synced 2026-02-16 17:45:24 -05:00
Base folds on buffer markers, since they don't rely on screen coords
When creating a display buffer for buffers that already have fold markers, which we'll eventually do on refresh, basing folds on full-blown display buffer markers is a problem because we end up creating display buffer markers during construction of the line map. When we create a display buffer marker it memoizes its screen positions, but since the line map isn't built yet we have nothing to translate against. Basically, since the line map depends on folds, folds can't depend on the line map. Luckily, they don't need to. Buffer markers work just fine.
This commit is contained in:
@@ -104,8 +104,8 @@ class DisplayBuffer
|
||||
# Returns the new {Fold}.
|
||||
createFold: (startRow, endRow) ->
|
||||
foldMarker =
|
||||
@findMarker({class: 'fold', startRow, endRow}) ?
|
||||
@markBufferRange([[startRow, 0], [endRow, Infinity]], class: 'fold')
|
||||
@buffer.findMarker({class: 'fold', startRow, endRow}) ?
|
||||
@buffer.markRange([[startRow, 0], [endRow, Infinity]], class: 'fold')
|
||||
@foldForMarker(foldMarker)
|
||||
|
||||
# Public: Removes any folds found that contain the given buffer row.
|
||||
@@ -129,7 +129,7 @@ class DisplayBuffer
|
||||
#
|
||||
# Returns an {Array} of {Fold}s.
|
||||
foldsStartingAtBufferRow: (bufferRow) ->
|
||||
for marker in @findMarkers(class: 'fold', startBufferRow: bufferRow)
|
||||
for marker in @buffer.findMarkers(class: 'fold', startRow: bufferRow)
|
||||
@foldForMarker(marker)
|
||||
|
||||
# Public: Given a screen row, this returns the largest fold that starts there.
|
||||
@@ -161,7 +161,7 @@ class DisplayBuffer
|
||||
#
|
||||
# Returns an {Array} of {Fold}s.
|
||||
foldsContainingBufferRow: (bufferRow) ->
|
||||
for marker in @findMarkers(class: 'fold', containsBufferRow: bufferRow)
|
||||
for marker in @buffer.findMarkers(class: 'fold', containsRow: bufferRow)
|
||||
@foldForMarker(marker)
|
||||
|
||||
# Public: Given a buffer range, this converts it into a screen range.
|
||||
@@ -375,9 +375,8 @@ class DisplayBuffer
|
||||
@triggerChanged(event, false)
|
||||
|
||||
handleMarkerCreated: (marker) =>
|
||||
marker = @getMarker(marker.id)
|
||||
new Fold(this, marker) if marker.matchesAttributes(class: 'fold')
|
||||
@trigger 'marker-created', marker
|
||||
@trigger 'marker-created', @getMarker(marker.id)
|
||||
|
||||
buildFoldForMarker: (marker) ->
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class Fold
|
||||
|
||||
# Returns the fold's {Range} in buffer coordinates
|
||||
getBufferRange: ->
|
||||
@marker.getBufferRange()
|
||||
@marker.getRange()
|
||||
|
||||
# Returns the fold's start row as a {Number}.
|
||||
getStartRow: ->
|
||||
|
||||
Reference in New Issue
Block a user