mirror of
https://github.com/atom/atom.git
synced 2026-02-12 15:45:23 -05:00
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:
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user