Merge pull request #11767 from atom/as-fix-bad-folded-rendering

Show folded marker in the first screen row of a soft-wrapped buffer row
This commit is contained in:
Antonio Scandurra
2016-05-16 13:47:49 +02:00
2 changed files with 22 additions and 11 deletions

View File

@@ -3069,15 +3069,28 @@ describe "TextEditorPresenter", ->
expect(lineNumberStateForScreenRow(presenter, 0).decorationClasses).toContain 'a'
expect(lineNumberStateForScreenRow(presenter, 1).decorationClasses).toContain 'a'
it "applies the 'folded' decoration only to the initial screen row of a soft-wrapped buffer row", ->
editor.setSoftWrapped(true)
editor.setDefaultCharWidth(1)
editor.setEditorWidthInChars(15)
editor.foldBufferRange([[0, 20], [0, 22]])
presenter = buildPresenter(explicitHeight: 35, scrollTop: 0, tileSize: 2)
describe "when a fold spans a single soft-wrapped buffer row", ->
it "applies the 'folded' decoration only to its initial screen row", ->
editor.setSoftWrapped(true)
editor.setDefaultCharWidth(1)
editor.setEditorWidthInChars(20)
editor.foldBufferRange([[0, 20], [0, 22]])
editor.foldBufferRange([[0, 10], [0, 14]])
presenter = buildPresenter(explicitHeight: 35, scrollTop: 0, tileSize: 2)
expect(lineNumberStateForScreenRow(presenter, 0).decorationClasses).toContain 'folded'
expect(lineNumberStateForScreenRow(presenter, 1).decorationClasses).toBeNull()
expect(lineNumberStateForScreenRow(presenter, 0).decorationClasses).toContain('folded')
expect(lineNumberStateForScreenRow(presenter, 1).decorationClasses).toBeNull()
describe "when a fold is at the end of a soft-wrapped buffer row", ->
it "applies the 'folded' decoration only to its initial screen row", ->
editor.setSoftWrapped(true)
editor.setDefaultCharWidth(1)
editor.setEditorWidthInChars(25)
editor.foldBufferRow(1)
presenter = buildPresenter(explicitHeight: 35, scrollTop: 0, tileSize: 2)
expect(lineNumberStateForScreenRow(presenter, 2).decorationClasses).toContain('folded')
expect(lineNumberStateForScreenRow(presenter, 3).decorationClasses).toBeNull()
describe ".foldable", ->
it "marks line numbers at the start of a foldable region as foldable", ->

View File

@@ -1153,13 +1153,11 @@ class TextEditorPresenter
if rangeIsReversed
headScreenPosition = screenRange.start
headBufferPosition = bufferRange.start
else
headScreenPosition = screenRange.end
headBufferPosition = bufferRange.end
if properties.class is 'folded' and Decoration.isType(properties, 'line-number')
screenRow = @model.screenRowForBufferRow(headBufferPosition.row)
screenRow = @model.screenRowForBufferRow(bufferRange.start.row)
@lineNumberDecorationsByScreenRow[screenRow] ?= {}
@lineNumberDecorationsByScreenRow[screenRow][decorationId] = properties
else