Merge branch 'master' into dh-async-repo

This commit is contained in:
joshaber
2015-12-14 23:29:11 -05:00
3 changed files with 37 additions and 245 deletions

View File

@@ -63,8 +63,8 @@
"atom-dark-ui": "0.51.0",
"atom-light-syntax": "0.28.0",
"atom-light-ui": "0.43.0",
"base16-tomorrow-dark-theme": "1.0.0",
"base16-tomorrow-light-theme": "1.0.0",
"base16-tomorrow-dark-theme": "1.1.0",
"base16-tomorrow-light-theme": "1.1.1",
"one-dark-ui": "1.1.9",
"one-dark-syntax": "1.1.1",
"one-light-syntax": "1.1.1",

View File

@@ -136,14 +136,6 @@ describe "TextEditorPresenter", ->
# clearing additional rows won't trigger a state update
expectNoStateUpdate presenter, -> presenter.clearScreenRowsToMeasure()
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]).toBeDefined()
expect(stateFn(presenter).tiles[12]).toBeDefined()
# when another change triggers a state update we remove useless lines
expectStateUpdate presenter, -> presenter.setScrollTop(1)
@@ -625,23 +617,6 @@ describe "TextEditorPresenter", ->
expect(getState(presenter).hiddenInput.width).toBe 2
describe ".content", ->
describe ".scrollingVertically", ->
it "is true for ::stoppedScrollingDelay milliseconds following a changes to ::scrollTop", ->
presenter = buildPresenter(scrollTop: 10, stoppedScrollingDelay: 200, explicitHeight: 100)
expect(getState(presenter).content.scrollingVertically).toBe true
advanceClock(300)
expect(getState(presenter).content.scrollingVertically).toBe false
expectStateUpdate presenter, -> presenter.setScrollTop(0)
expect(getState(presenter).content.scrollingVertically).toBe true
advanceClock(100)
expect(getState(presenter).content.scrollingVertically).toBe true
presenter.setScrollTop(10)
getState(presenter) # commits scroll position
advanceClock(100)
expect(getState(presenter).content.scrollingVertically).toBe true
expectStateUpdate presenter, -> advanceClock(100)
expect(getState(presenter).content.scrollingVertically).toBe false
describe ".maxHeight", ->
it "changes based on boundingClientRect", ->
presenter = buildPresenter(scrollTop: 0, lineHeight: 10)

View File

@@ -86,11 +86,7 @@ class TextEditorPresenter
@fetchDecorations()
@updateLineDecorations()
if @shouldUpdateLinesState or @shouldUpdateLineNumbersState
@updateTilesState()
@shouldUpdateLinesState = false
@shouldUpdateLineNumbersState = false
@shouldUpdateTilesState = true
@updateTilesState()
@updating = false
@state
@@ -104,105 +100,47 @@ class TextEditorPresenter
@clearPendingScrollPosition()
@updateRowsPerPage()
@updateFocusedState() if @shouldUpdateFocusedState
@updateHeightState() if @shouldUpdateHeightState
@updateVerticalScrollState() if @shouldUpdateVerticalScrollState
@updateHorizontalScrollState() if @shouldUpdateHorizontalScrollState
@updateScrollbarsState() if @shouldUpdateScrollbarsState
@updateHiddenInputState() if @shouldUpdateHiddenInputState
@updateContentState() if @shouldUpdateContentState
@updateFocusedState()
@updateHeightState()
@updateVerticalScrollState()
@updateHorizontalScrollState()
@updateScrollbarsState()
@updateHiddenInputState()
@updateContentState()
@updateHighlightDecorations() if @shouldUpdateDecorations
@updateTilesState() if @shouldUpdateTilesState
@updateCursorsState() if @shouldUpdateCursorsState
@updateOverlaysState() if @shouldUpdateOverlaysState
@updateLineNumberGutterState() if @shouldUpdateLineNumberGutterState
@updateGutterOrderState() if @shouldUpdateGutterOrderState
@updateCustomGutterDecorationState() if @shouldUpdateCustomGutterDecorationState
@updateTilesState()
@updateCursorsState()
@updateOverlaysState()
@updateLineNumberGutterState()
@updateGutterOrderState()
@updateCustomGutterDecorationState()
@updating = false
@resetTrackedUpdates()
@state
resetTrackedUpdates: ->
@shouldUpdateFocusedState = false
@shouldUpdateHeightState = false
@shouldUpdateVerticalScrollState = false
@shouldUpdateHorizontalScrollState = false
@shouldUpdateScrollbarsState = false
@shouldUpdateHiddenInputState = false
@shouldUpdateContentState = false
@shouldUpdateDecorations = false
@shouldUpdateLinesState = false
@shouldUpdateTilesState = false
@shouldUpdateCursorsState = false
@shouldUpdateOverlaysState = false
@shouldUpdateLineNumberGutterState = false
@shouldUpdateLineNumbersState = false
@shouldUpdateGutterOrderState = false
@shouldUpdateCustomGutterDecorationState = false
invalidateState: ->
@shouldUpdateFocusedState = true
@shouldUpdateHeightState = true
@shouldUpdateVerticalScrollState = true
@shouldUpdateHorizontalScrollState = true
@shouldUpdateScrollbarsState = true
@shouldUpdateHiddenInputState = true
@shouldUpdateContentState = true
@shouldUpdateDecorations = true
@shouldUpdateLinesState = true
@shouldUpdateTilesState = true
@shouldUpdateCursorsState = true
@shouldUpdateOverlaysState = true
@shouldUpdateLineNumberGutterState = true
@shouldUpdateLineNumbersState = true
@shouldUpdateGutterOrderState = true
@shouldUpdateCustomGutterDecorationState = true
observeModel: ->
@disposables.add @model.onDidChange =>
@shouldUpdateHeightState = true
@shouldUpdateVerticalScrollState = true
@shouldUpdateHorizontalScrollState = true
@shouldUpdateScrollbarsState = true
@shouldUpdateContentState = true
@shouldUpdateDecorations = true
@shouldUpdateCursorsState = true
@shouldUpdateLinesState = true
@shouldUpdateLineNumberGutterState = true
@shouldUpdateLineNumbersState = true
@shouldUpdateGutterOrderState = true
@shouldUpdateCustomGutterDecorationState = true
@emitDidUpdateState()
@disposables.add @model.onDidUpdateDecorations =>
@shouldUpdateLinesState = true
@shouldUpdateLineNumbersState = true
@shouldUpdateDecorations = true
@shouldUpdateOverlaysState = true
@shouldUpdateCustomGutterDecorationState = true
@emitDidUpdateState()
@disposables.add @model.onDidChangeGrammar(@didChangeGrammar.bind(this))
@disposables.add @model.onDidChangePlaceholderText =>
@shouldUpdateContentState = true
@emitDidUpdateState()
@disposables.add @model.onDidChangePlaceholderText(@emitDidUpdateState.bind(this))
@disposables.add @model.onDidChangeMini =>
@shouldUpdateScrollbarsState = true
@shouldUpdateContentState = true
@shouldUpdateDecorations = true
@shouldUpdateLinesState = true
@shouldUpdateLineNumberGutterState = true
@shouldUpdateLineNumbersState = true
@shouldUpdateGutterOrderState = true
@shouldUpdateCustomGutterDecorationState = true
@emitDidUpdateState()
@disposables.add @model.onDidChangeLineNumberGutterVisible =>
@shouldUpdateLineNumberGutterState = true
@shouldUpdateGutterOrderState = true
@emitDidUpdateState()
@disposables.add @model.onDidChangeLineNumberGutterVisible(@emitDidUpdateState.bind(this))
@disposables.add @model.onDidAddCursor(@didAddCursor.bind(this))
@disposables.add @model.onDidRequestAutoscroll(@requestAutoscroll.bind(this))
@@ -227,29 +165,19 @@ class TextEditorPresenter
@configDisposables.add @config.onDidChange 'editor.showIndentGuide', configParams, ({newValue}) =>
@showIndentGuide = newValue
@shouldUpdateContentState = true
@emitDidUpdateState()
@configDisposables.add @config.onDidChange 'editor.scrollPastEnd', configParams, ({newValue}) =>
@scrollPastEnd = newValue
@shouldUpdateVerticalScrollState = true
@shouldUpdateScrollbarsState = true
@updateScrollHeight()
@emitDidUpdateState()
@configDisposables.add @config.onDidChange 'editor.showLineNumbers', configParams, ({newValue}) =>
@showLineNumbers = newValue
@shouldUpdateLineNumberGutterState = true
@shouldUpdateGutterOrderState = true
@emitDidUpdateState()
didChangeGrammar: ->
@observeConfig()
@shouldUpdateContentState = true
@shouldUpdateLineNumberGutterState = true
@shouldUpdateGutterOrderState = true
@emitDidUpdateState()
buildState: ->
@@ -383,8 +311,6 @@ class TextEditorPresenter
return if not screenRows? or screenRows.length is 0
@screenRowsToMeasure = screenRows
@shouldUpdateLinesState = true
@shouldUpdateLineNumbersState = true
@shouldUpdateDecorations = true
clearScreenRowsToMeasure: ->
@@ -425,8 +351,8 @@ class TextEditorPresenter
gutterTile.display = "block"
gutterTile.zIndex = zIndex
@updateLinesState(tile, rowsWithinTile) if @shouldUpdateLinesState
@updateLineNumbersState(gutterTile, rowsWithinTile) if @shouldUpdateLineNumbersState
@updateLinesState(tile, rowsWithinTile)
@updateLineNumbersState(gutterTile, rowsWithinTile)
visibleTiles[tileStartRow] = true
zIndex++
@@ -551,24 +477,15 @@ class TextEditorPresenter
didAddGutter: (gutter) ->
gutterDisposables = new CompositeDisposable
gutterDisposables.add gutter.onDidChangeVisible =>
@shouldUpdateGutterOrderState = true
@shouldUpdateCustomGutterDecorationState = true
@emitDidUpdateState()
gutterDisposables.add gutter.onDidChangeVisible => @emitDidUpdateState()
gutterDisposables.add gutter.onDidDestroy =>
@disposables.remove(gutterDisposables)
gutterDisposables.dispose()
@shouldUpdateGutterOrderState = true
@emitDidUpdateState()
# It is not necessary to @updateCustomGutterDecorationState here.
# The destroyed gutter will be removed from the list of gutters in @state,
# and thus will be removed from the DOM.
@disposables.add(gutterDisposables)
@shouldUpdateGutterOrderState = true
@shouldUpdateCustomGutterDecorationState = true
@emitDidUpdateState()
updateGutterOrderState: ->
@@ -861,26 +778,15 @@ class TextEditorPresenter
@startBlinkingCursors()
else
@stopBlinkingCursors(false)
@shouldUpdateFocusedState = true
@shouldUpdateHiddenInputState = true
@emitDidUpdateState()
setScrollTop: (scrollTop, overrideScroll=true) ->
setScrollTop: (scrollTop) ->
return unless scrollTop?
@pendingScrollLogicalPosition = null if overrideScroll
@pendingScrollLogicalPosition = null
@pendingScrollTop = scrollTop
@shouldUpdateVerticalScrollState = true
@shouldUpdateHiddenInputState = true
@shouldUpdateDecorations = true
@shouldUpdateLinesState = true
@shouldUpdateCursorsState = true
@shouldUpdateLineNumbersState = true
@shouldUpdateCustomGutterDecorationState = true
@shouldUpdateOverlaysState = true
@emitDidUpdateState()
getScrollTop: ->
@@ -894,32 +800,19 @@ class TextEditorPresenter
clearTimeout(@stoppedScrollingTimeoutId)
@stoppedScrollingTimeoutId = null
@stoppedScrollingTimeoutId = setTimeout(@didStopScrolling.bind(this), @stoppedScrollingDelay)
@state.content.scrollingVertically = true
@emitDidUpdateState()
didStopScrolling: ->
@state.content.scrollingVertically = false
if @mouseWheelScreenRow?
@mouseWheelScreenRow = null
@shouldUpdateLinesState = true
@shouldUpdateLineNumbersState = true
@shouldUpdateCustomGutterDecorationState = true
@emitDidUpdateState()
setScrollLeft: (scrollLeft, overrideScroll=true) ->
setScrollLeft: (scrollLeft) ->
return unless scrollLeft?
@pendingScrollLogicalPosition = null if overrideScroll
@pendingScrollLogicalPosition = null
@pendingScrollLeft = scrollLeft
@shouldUpdateHorizontalScrollState = true
@shouldUpdateHiddenInputState = true
@shouldUpdateCursorsState = true
@shouldUpdateOverlaysState = true
@shouldUpdateDecorations = true
@shouldUpdateLinesState = true
@emitDidUpdateState()
getScrollLeft: ->
@@ -941,13 +834,13 @@ class TextEditorPresenter
@contentFrameWidth - @verticalScrollbarWidth
getScrollBottom: -> @getScrollTop() + @getClientHeight()
setScrollBottom: (scrollBottom, overrideScroll) ->
@setScrollTop(scrollBottom - @getClientHeight(), overrideScroll)
setScrollBottom: (scrollBottom) ->
@setScrollTop(scrollBottom - @getClientHeight())
@getScrollBottom()
getScrollRight: -> @getScrollLeft() + @getClientWidth()
setScrollRight: (scrollRight, overrideScroll) ->
@setScrollLeft(scrollRight - @getClientWidth(), overrideScroll)
setScrollRight: (scrollRight) ->
@setScrollLeft(scrollRight - @getClientWidth())
@getScrollRight()
getScrollHeight: ->
@@ -967,43 +860,24 @@ class TextEditorPresenter
unless @measuredHorizontalScrollbarHeight is horizontalScrollbarHeight
oldHorizontalScrollbarHeight = @measuredHorizontalScrollbarHeight
@measuredHorizontalScrollbarHeight = horizontalScrollbarHeight
@shouldUpdateScrollbarsState = true
@shouldUpdateVerticalScrollState = true
@shouldUpdateHorizontalScrollState = true
@shouldUpdateCursorsState = true unless oldHorizontalScrollbarHeight?
@emitDidUpdateState()
setVerticalScrollbarWidth: (verticalScrollbarWidth) ->
unless @measuredVerticalScrollbarWidth is verticalScrollbarWidth
oldVerticalScrollbarWidth = @measuredVerticalScrollbarWidth
@measuredVerticalScrollbarWidth = verticalScrollbarWidth
@shouldUpdateScrollbarsState = true
@shouldUpdateVerticalScrollState = true
@shouldUpdateHorizontalScrollState = true
@shouldUpdateCursorsState = true unless oldVerticalScrollbarWidth?
@emitDidUpdateState()
setAutoHeight: (autoHeight) ->
unless @autoHeight is autoHeight
@autoHeight = autoHeight
@shouldUpdateHeightState = true
@emitDidUpdateState()
setExplicitHeight: (explicitHeight) ->
unless @explicitHeight is explicitHeight
@explicitHeight = explicitHeight
@updateHeight()
@shouldUpdateVerticalScrollState = true
@shouldUpdateScrollbarsState = true
@shouldUpdateDecorations = true
@shouldUpdateLinesState = true
@shouldUpdateCursorsState = true
@shouldUpdateLineNumbersState = true
@shouldUpdateCustomGutterDecorationState = true
@emitDidUpdateState()
updateHeight: ->
@@ -1022,22 +896,12 @@ class TextEditorPresenter
@editorWidthInChars = null
@updateScrollbarDimensions()
@updateClientWidth()
@shouldUpdateVerticalScrollState = true
@shouldUpdateHorizontalScrollState = true
@shouldUpdateScrollbarsState = true
@shouldUpdateContentState = true
@shouldUpdateDecorations = true
@shouldUpdateLinesState = true
@shouldUpdateCursorsState = true unless oldContentFrameWidth?
@emitDidUpdateState()
setBoundingClientRect: (boundingClientRect) ->
unless @clientRectsEqual(@boundingClientRect, boundingClientRect)
@boundingClientRect = boundingClientRect
@shouldUpdateOverlaysState = true
@shouldUpdateContentState = true
@emitDidUpdateState()
clientRectsEqual: (clientRectA, clientRectB) ->
@@ -1051,25 +915,17 @@ class TextEditorPresenter
if @windowWidth isnt width or @windowHeight isnt height
@windowWidth = width
@windowHeight = height
@shouldUpdateOverlaysState = true
@emitDidUpdateState()
setBackgroundColor: (backgroundColor) ->
unless @backgroundColor is backgroundColor
@backgroundColor = backgroundColor
@shouldUpdateContentState = true
@shouldUpdateLineNumberGutterState = true
@shouldUpdateGutterOrderState = true
@emitDidUpdateState()
setGutterBackgroundColor: (gutterBackgroundColor) ->
unless @gutterBackgroundColor is gutterBackgroundColor
@gutterBackgroundColor = gutterBackgroundColor
@shouldUpdateLineNumberGutterState = true
@shouldUpdateGutterOrderState = true
@emitDidUpdateState()
setGutterWidth: (gutterWidth) ->
@@ -1085,18 +941,7 @@ class TextEditorPresenter
@lineHeight = lineHeight
@restoreScrollTopIfNeeded()
@model.setLineHeightInPixels(lineHeight)
@shouldUpdateHeightState = true
@shouldUpdateHorizontalScrollState = true
@shouldUpdateVerticalScrollState = true
@shouldUpdateScrollbarsState = true
@shouldUpdateHiddenInputState = true
@shouldUpdateDecorations = true
@shouldUpdateLinesState = true
@shouldUpdateCursorsState = true
@shouldUpdateLineNumbersState = true
@shouldUpdateCustomGutterDecorationState = true
@shouldUpdateOverlaysState = true
@emitDidUpdateState()
setMouseWheelScreenRow: (screenRow) ->
@@ -1115,16 +960,7 @@ class TextEditorPresenter
@characterWidthsChanged()
characterWidthsChanged: ->
@shouldUpdateHorizontalScrollState = true
@shouldUpdateVerticalScrollState = true
@shouldUpdateScrollbarsState = true
@shouldUpdateHiddenInputState = true
@shouldUpdateContentState = true
@shouldUpdateDecorations = true
@shouldUpdateLinesState = true
@shouldUpdateCursorsState = true
@shouldUpdateOverlaysState = true
@emitDidUpdateState()
hasPixelPositionRequirements: ->
@@ -1365,20 +1201,16 @@ class TextEditorPresenter
overlayState.itemWidth = itemWidth
overlayState.itemHeight = itemHeight
overlayState.contentMargin = contentMargin
@shouldUpdateOverlaysState = true
@emitDidUpdateState()
observeCursor: (cursor) ->
didChangePositionDisposable = cursor.onDidChangePosition =>
@shouldUpdateHiddenInputState = true if cursor.isLastCursor()
@shouldUpdateCursorsState = true
@pauseCursorBlinking()
@emitDidUpdateState()
didChangeVisibilityDisposable = cursor.onDidChangeVisibility =>
@shouldUpdateCursorsState = true
@emitDidUpdateState()
@@ -1386,8 +1218,6 @@ class TextEditorPresenter
@disposables.remove(didChangePositionDisposable)
@disposables.remove(didChangeVisibilityDisposable)
@disposables.remove(didDestroyDisposable)
@shouldUpdateHiddenInputState = true
@shouldUpdateCursorsState = true
@emitDidUpdateState()
@@ -1397,8 +1227,6 @@ class TextEditorPresenter
didAddCursor: (cursor) ->
@observeCursor(cursor)
@shouldUpdateHiddenInputState = true
@shouldUpdateCursorsState = true
@pauseCursorBlinking()
@emitDidUpdateState()
@@ -1432,18 +1260,7 @@ class TextEditorPresenter
@pendingScrollLogicalPosition = position
@pendingScrollTop = null
@pendingScrollLeft = null
@shouldUpdateCursorsState = true
@shouldUpdateCustomGutterDecorationState = true
@shouldUpdateDecorations = true
@shouldUpdateHiddenInputState = true
@shouldUpdateHorizontalScrollState = true
@shouldUpdateLinesState = true
@shouldUpdateLineNumbersState = true
@shouldUpdateOverlaysState = true
@shouldUpdateScrollPosition = true
@shouldUpdateVerticalScrollState = true
@emitDidUpdateState()
didChangeFirstVisibleScreenRow: (screenRow) ->
@@ -1482,14 +1299,14 @@ class TextEditorPresenter
if options?.reversed ? true
if desiredScrollBottom > @getScrollBottom()
@setScrollBottom(desiredScrollBottom, false)
@updateScrollTop(desiredScrollBottom - @getClientHeight())
if desiredScrollTop < @getScrollTop()
@setScrollTop(desiredScrollTop, false)
@updateScrollTop(desiredScrollTop)
else
if desiredScrollTop < @getScrollTop()
@setScrollTop(desiredScrollTop, false)
@updateScrollTop(desiredScrollTop)
if desiredScrollBottom > @getScrollBottom()
@setScrollBottom(desiredScrollBottom, false)
@updateScrollTop(desiredScrollBottom - @getClientHeight())
commitPendingLogicalScrollLeftPosition: ->
return unless @pendingScrollLogicalPosition?
@@ -1509,14 +1326,14 @@ class TextEditorPresenter
if options?.reversed ? true
if desiredScrollRight > @getScrollRight()
@setScrollRight(desiredScrollRight, false)
@updateScrollLeft(desiredScrollRight - @getClientWidth())
if desiredScrollLeft < @getScrollLeft()
@setScrollLeft(desiredScrollLeft, false)
@updateScrollLeft(desiredScrollLeft)
else
if desiredScrollLeft < @getScrollLeft()
@setScrollLeft(desiredScrollLeft, false)
@updateScrollLeft(desiredScrollLeft)
if desiredScrollRight > @getScrollRight()
@setScrollRight(desiredScrollRight, false)
@updateScrollLeft(desiredScrollRight - @getClientWidth())
commitPendingScrollLeftPosition: ->
if @pendingScrollLeft?