From 74e4756ef0dcccdba8c8cef58837172cd0997129 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 29 Jan 2015 15:33:25 -0700 Subject: [PATCH] =?UTF-8?q?:racehorse:=20Don=E2=80=99t=20update=20presente?= =?UTF-8?q?r=20state=20unless=20measurements=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/text-editor-presenter.coffee | 102 ++++++++++++++++++------------- 1 file changed, 61 insertions(+), 41 deletions(-) diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 6b14d7731..1ca825f45 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -429,13 +429,15 @@ class TextEditorPresenter hasRequiredMeasurements: -> @getLineHeight()? and @getBaseCharacterWidth()? and @getHeight()? and @getScrollTop()? - setScrollTop: (@scrollTop) -> - @didStartScrolling() - @updateVerticalScrollState() - @updateLinesState() - @updateCursorsState() - @updateHighlightsState() - @updateLineNumbersState() + setScrollTop: (scrollTop) -> + unless @scrollTop is scrollTop + @scrollTop = scrollTop + @didStartScrolling() + @updateVerticalScrollState() + @updateLinesState() + @updateCursorsState() + @updateHighlightsState() + @updateLineNumbersState() didStartScrolling: -> if @stoppedScrollingTimeoutId? @@ -456,77 +458,95 @@ class TextEditorPresenter getScrollTop: -> @scrollTop - setScrollLeft: (@scrollLeft) -> - @updateHorizontalScrollState() + setScrollLeft: (scrollLeft) -> + unless @scrollLeft is scrollLeft + @scrollLeft = scrollLeft + @updateHorizontalScrollState() getScrollLeft: -> @scrollLeft - setHorizontalScrollbarHeight: (@horizontalScrollbarHeight) -> - @updateScrollbarsState() + setHorizontalScrollbarHeight: (horizontalScrollbarHeight) -> + unless @horizontalScrollbarHeight is horizontalScrollbarHeight + @horizontalScrollbarHeight = horizontalScrollbarHeight + @updateScrollbarsState() getHorizontalScrollbarHeight: -> @horizontalScrollbarHeight - setVerticalScrollbarWidth: (@verticalScrollbarWidth) -> - @updateScrollbarsState() + setVerticalScrollbarWidth: (verticalScrollbarWidth) -> + unless @verticalScrollbarWidth is verticalScrollbarWidth + @verticalScrollbarWidth = verticalScrollbarWidth + @updateScrollbarsState() getVerticalScrollbarWidth: -> @verticalScrollbarWidth - setAutoHeight: (@autoHeight) -> - @updateHeightState() + setAutoHeight: (autoHeight) -> + unless @autoHeight is autoHeight + @autoHeight = autoHeight + @updateHeightState() hasAutoHeight: -> @autoHeight - setHeight: (@height) -> - @updateVerticalScrollState() - @updateScrollbarsState() - @updateLinesState() - @updateCursorsState() - @updateHighlightsState() - @updateLineNumbersState() + setHeight: (height) -> + unless @height is height + @height = height + @updateVerticalScrollState() + @updateScrollbarsState() + @updateLinesState() + @updateCursorsState() + @updateHighlightsState() + @updateLineNumbersState() getHeight: -> @height ? @computeContentHeight() - setContentFrameWidth: (@contentFrameWidth) -> - @updateHorizontalScrollState() - @updateScrollbarsState() - @updateContentState() - @updateLinesState() + setContentFrameWidth: (contentFrameWidth) -> + unless @contentFrameWidth is contentFrameWidth + @contentFrameWidth = contentFrameWidth + @updateHorizontalScrollState() + @updateScrollbarsState() + @updateContentState() + @updateLinesState() getContentFrameWidth: -> @contentFrameWidth setBackgroundColor: (backgroundColor) -> - if backgroundColor isnt @backgroundColor + unless @backgroundColor is backgroundColor @backgroundColor = backgroundColor @updateContentState() getBackgroundColor: -> @backgroundColor setGutterBackgroundColor: (gutterBackgroundColor) -> - if gutterBackgroundColor isnt @gutterBackgroundColor + unless @gutterBackgroundColor is gutterBackgroundColor @gutterBackgroundColor = gutterBackgroundColor @updateGutterState() getGutterBackgroundColor: -> @gutterBackgroundColor - setLineHeight: (@lineHeight) -> - @updateHeightState() - @updateVerticalScrollState() - @updateLinesState() - @updateCursorsState() - @updateHighlightsState() - @updateLineNumbersState() - @updateOverlaysState() + setLineHeight: (lineHeight) -> + unless @lineHeight is lineHeight + @lineHeight = lineHeight + @updateHeightState() + @updateVerticalScrollState() + @updateLinesState() + @updateCursorsState() + @updateHighlightsState() + @updateLineNumbersState() + @updateOverlaysState() getLineHeight: -> @lineHeight - setMouseWheelScreenRow: (@mouseWheelScreenRow) -> - @didStartScrolling() + setMouseWheelScreenRow: (mouseWheelScreenRow) -> + unless @mouseWheelScreenRow is mouseWheelScreenRow + @mouseWheelScreenRow = mouseWheelScreenRow + @didStartScrolling() getMouseWheelScreenRow: -> @mouseWheelScreenRow - setBaseCharacterWidth: (@baseCharacterWidth) -> - @characterWidthsChanged() + setBaseCharacterWidth: (baseCharacterWidth) -> + unless @baseCharacterWidth is baseCharacterWidth + @baseCharacterWidth = baseCharacterWidth + @characterWidthsChanged() getBaseCharacterWidth: -> @baseCharacterWidth