mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
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:
@@ -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", ->
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user