From 97125ad083e7a1d21396034a37485689f8a1950b Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 24 Apr 2017 14:35:17 +0200 Subject: [PATCH] Update gutter container only once per frame unless its width changes Signed-off-by: Nathan Sobo --- src/text-editor-component.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index 79798c7d6..f8ef0af26 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -330,9 +330,7 @@ class TextEditorComponent { measureContentDuringUpdateSync () { if (this.remeasureGutterDimensions) { - if (this.measureGutterDimensions()) { - // TODO: Ensure we update the gutter container in the second phase of the update - } + this.measureGutterDimensions() this.remeasureGutterDimensions = false } const wasHorizontalScrollbarVisible = this.isHorizontalScrollbarVisible() @@ -456,6 +454,7 @@ class TextEditorComponent { key: 'gutterContainer', rootComponent: this, hasInitialMeasurements: this.hasInitialMeasurements, + measuredContent: this.measuredContent, scrollTop: this.getScrollTop(), scrollHeight: this.getScrollHeight(), lineNumberGutterWidth: this.getLineNumberGutterWidth(), @@ -2564,8 +2563,17 @@ class GutterContainerComponent { } update (props) { - this.props = props - etch.updateSync(this) + if (this.shouldUpdate(props)) { + this.props = props + etch.updateSync(this) + } + } + + shouldUpdate (props) { + return ( + !props.measuredContent || + props.lineNumberGutterWidth !== this.props.lineNumberGutterWidth + ) } render () {