Apply 'folded' decoration only to 1st screen row of a wrapped buffer row

This commit is contained in:
Antonio Scandurra
2016-04-26 12:11:05 +02:00
parent 4f6687324e
commit f81f54e08a
3 changed files with 40 additions and 15 deletions

View File

@@ -1127,9 +1127,9 @@ class TextEditorPresenter
@customGutterDecorationsByGutterName = {}
for decorationId, decorationState of @decorations
{properties, screenRange, rangeIsReversed} = decorationState
{properties, bufferRange, screenRange, rangeIsReversed} = decorationState
if Decoration.isType(properties, 'line') or Decoration.isType(properties, 'line-number')
@addToLineDecorationCaches(decorationId, properties, screenRange, rangeIsReversed)
@addToLineDecorationCaches(decorationId, properties, bufferRange, screenRange, rangeIsReversed)
else if Decoration.isType(properties, 'gutter') and properties.gutterName?
@customGutterDecorationsByGutterName[properties.gutterName] ?= {}
@@ -1150,7 +1150,7 @@ class TextEditorPresenter
return
addToLineDecorationCaches: (decorationId, properties, screenRange, rangeIsReversed) ->
addToLineDecorationCaches: (decorationId, properties, bufferRange, screenRange, rangeIsReversed) ->
if screenRange.isEmpty()
return if properties.onlyNonEmpty
else
@@ -1158,21 +1158,28 @@ class TextEditorPresenter
omitLastRow = screenRange.end.column is 0
if rangeIsReversed
headPosition = screenRange.start
headScreenPosition = screenRange.start
headBufferPosition = bufferRange.start
else
headPosition = screenRange.end
headScreenPosition = screenRange.end
headBufferPosition = bufferRange.end
for row in [screenRange.start.row..screenRange.end.row] by 1
continue if properties.onlyHead and row isnt headPosition.row
continue if omitLastRow and row is screenRange.end.row
if properties.class is 'folded' and Decoration.isType(properties, 'line-number')
screenRow = @model.screenRowForBufferRow(headBufferPosition.row)
@lineNumberDecorationsByScreenRow[screenRow] ?= {}
@lineNumberDecorationsByScreenRow[screenRow][decorationId] = properties
else
for row in [screenRange.start.row..screenRange.end.row] by 1
continue if properties.onlyHead and row isnt headScreenPosition.row
continue if omitLastRow and row is screenRange.end.row
if Decoration.isType(properties, 'line')
@lineDecorationsByScreenRow[row] ?= {}
@lineDecorationsByScreenRow[row][decorationId] = properties
if Decoration.isType(properties, 'line')
@lineDecorationsByScreenRow[row] ?= {}
@lineDecorationsByScreenRow[row][decorationId] = properties
if Decoration.isType(properties, 'line-number')
@lineNumberDecorationsByScreenRow[row] ?= {}
@lineNumberDecorationsByScreenRow[row][decorationId] = properties
if Decoration.isType(properties, 'line-number')
@lineNumberDecorationsByScreenRow[row] ?= {}
@lineNumberDecorationsByScreenRow[row][decorationId] = properties
return