Decide to measure gutter's width in gutter

The gutter is in a better position to determine if the max line number
length has changed because it's a property that gets passed in so we
can compare current with previous.

Fixes #2659
This commit is contained in:
Nathan Sobo
2014-06-18 21:07:13 -06:00
parent 33c9d5ae24
commit 609855af3c
2 changed files with 14 additions and 7 deletions

View File

@@ -12,6 +12,7 @@ GutterComponent = React.createClass
mixins: [SubscriberMixin]
dummyLineNumberNode: null
measuredWidth: null
render: ->
{scrollHeight, scrollViewHeight, scrollTop} = @props
@@ -48,10 +49,13 @@ GutterComponent = React.createClass
false
componentDidUpdate: (oldProps) ->
unless oldProps.maxLineNumberDigits is @props.maxLineNumberDigits
unless isEqualForProperties(oldProps, @props, 'maxLineNumberDigits')
@updateDummyLineNumber()
@removeLineNumberNodes()
unless isEqualForProperties(oldProps, @props, 'maxLineNumberDigits', 'defaultCharWidth')
@measureWidth()
@clearScreenRowCaches() unless oldProps.lineHeightInPixels is @props.lineHeightInPixels
@updateLineNumbers()
@@ -202,6 +206,12 @@ GutterComponent = React.createClass
else
editor.foldBufferRow(bufferRow)
measureWidth: ->
width = @getDOMNode().offsetWidth
unless width is @measuredWidth
@measuredWidth = width
@props.onWidthChanged?(width)
# Created because underscore uses === not _.isEqual, which we need
contains = (array, target) ->
return false unless array?