Merge pull request #13202 from atom/mb-fix-resize-flicker

Fix flicker in soft-wrapped files when resizing editors
This commit is contained in:
Max Brunsfeld
2016-11-11 13:37:12 -08:00
committed by GitHub
3 changed files with 21 additions and 34 deletions

View File

@@ -165,23 +165,6 @@ describe "TextEditorPresenter", ->
expect(stateFn(presenter).tiles[10]).toBeUndefined()
expect(stateFn(presenter).tiles[12]).toBeUndefined()
it "excludes invalid tiles for screen rows to measure", ->
presenter = buildPresenter(explicitHeight: 6, scrollTop: 0, lineHeight: 1, tileSize: 2)
presenter.setScreenRowsToMeasure([20, 30]) # unexisting rows
expect(stateFn(presenter).tiles[0]).toBeDefined()
expect(stateFn(presenter).tiles[2]).toBeDefined()
expect(stateFn(presenter).tiles[4]).toBeDefined()
expect(stateFn(presenter).tiles[6]).toBeDefined()
expect(stateFn(presenter).tiles[8]).toBeUndefined()
expect(stateFn(presenter).tiles[10]).toBeUndefined()
expect(stateFn(presenter).tiles[12]).toBeUndefined()
presenter.setScreenRowsToMeasure([12])
buffer.deleteRows(12, 13)
expect(stateFn(presenter).tiles[12]).toBeUndefined()
describe "when there are block decorations", ->
it "computes each tile's height and scrollTop based on block decorations' height", ->
presenter = buildPresenter(explicitHeight: 120, scrollTop: 0, lineHeight: 10, tileSize: 2)

View File

@@ -306,9 +306,6 @@ class TextEditorPresenter
getEndTileRow: ->
@tileForRow(@endRow ? 0)
isValidScreenRow: (screenRow) ->
screenRow >= 0 and screenRow < @model.getApproximateScreenLineCount()
getScreenRowsToRender: ->
startRow = @getStartTileRow()
endRow = @getEndTileRow() + @tileSize
@@ -320,7 +317,7 @@ class TextEditorPresenter
if @screenRowsToMeasure?
screenRows.push(@screenRowsToMeasure...)
screenRows = screenRows.filter @isValidScreenRow.bind(this)
screenRows = screenRows.filter (row) -> row >= 0
screenRows.sort (a, b) -> a - b
_.uniq(screenRows, true)
@@ -395,19 +392,17 @@ class TextEditorPresenter
visibleTiles[tileStartRow] = true
zIndex++
if @mouseWheelScreenRow? and 0 <= @mouseWheelScreenRow < @model.getApproximateScreenLineCount()
mouseWheelTile = @tileForRow(@mouseWheelScreenRow)
unless visibleTiles[mouseWheelTile]?
@lineNumberGutter.tiles[mouseWheelTile].display = "none"
@state.content.tiles[mouseWheelTile].display = "none"
visibleTiles[mouseWheelTile] = true
mouseWheelTileId = @tileForRow(@mouseWheelScreenRow) if @mouseWheelScreenRow?
for id, tile of @state.content.tiles
continue if visibleTiles.hasOwnProperty(id)
delete @state.content.tiles[id]
delete @lineNumberGutter.tiles[id]
if Number(id) is mouseWheelTileId
@state.content.tiles[id].display = "none"
@lineNumberGutter.tiles[id].display = "none"
else
delete @state.content.tiles[id]
delete @lineNumberGutter.tiles[id]
updateLinesState: (tileState, screenRows) ->
tileState.lines ?= {}

View File

@@ -222,6 +222,7 @@ class TextEditor extends Model
@backgroundWorkHandle = null
update: (params) ->
currentSoftWrapColumn = @getSoftWrapColumn()
displayLayerParams = {}
for param in Object.keys(params)
@@ -272,12 +273,16 @@ class TextEditor extends Model
when 'softWrapAtPreferredLineLength'
if value isnt @softWrapAtPreferredLineLength
@softWrapAtPreferredLineLength = value
displayLayerParams.softWrapColumn = @getSoftWrapColumn() if @isSoftWrapped()
softWrapColumn = @getSoftWrapColumn()
if softWrapColumn isnt currentSoftWrapColumn
displayLayerParams.softWrapColumn = softWrapColumn
when 'preferredLineLength'
if value isnt @preferredLineLength
@preferredLineLength = value
displayLayerParams.softWrapColumn = @getSoftWrapColumn() if @isSoftWrapped()
softWrapColumn = @getSoftWrapColumn()
if softWrapColumn isnt currentSoftWrapColumn
displayLayerParams.softWrapColumn = softWrapColumn
when 'mini'
if value isnt @mini
@@ -322,12 +327,16 @@ class TextEditor extends Model
when 'editorWidthInChars'
if value > 0 and value isnt @editorWidthInChars
@editorWidthInChars = value
displayLayerParams.softWrapColumn = @getSoftWrapColumn() if @isSoftWrapped()
softWrapColumn = @getSoftWrapColumn()
if softWrapColumn isnt currentSoftWrapColumn
displayLayerParams.softWrapColumn = softWrapColumn
when 'width'
if value isnt @width
@width = value
displayLayerParams.softWrapColumn = @getSoftWrapColumn() if @isSoftWrapped()
softWrapColumn = @getSoftWrapColumn()
if softWrapColumn isnt currentSoftWrapColumn
displayLayerParams.softWrapColumn = softWrapColumn
when 'scrollPastEnd'
if value isnt @scrollPastEnd