From 245f294cc3bb91ed8701b2f4028af94cac1f4101 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 5 May 2017 19:55:57 +0200 Subject: [PATCH] Call `editor.setEditorWidthInChars` only when the value changed Signed-off-by: Nathan Sobo --- src/text-editor-component.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index 87f66875a..6d3ca9cc5 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -1964,10 +1964,15 @@ class TextEditorComponent { } updateModelSoftWrapColumn () { - this.suppressUpdates = true - this.props.model.setEditorWidthInChars(this.getScrollContainerClientWidthInBaseCharacters()) - this.props.model.setEditorWidthInChars(this.getScrollContainerClientWidthInBaseCharacters()) - this.suppressUpdates = false + const {model} = this.props + const newEditorWidthInChars = this.getScrollContainerClientWidthInBaseCharacters() + if (newEditorWidthInChars !== model.getEditorWidthInChars()) { + this.suppressUpdates = true + this.props.model.setEditorWidthInChars(newEditorWidthInChars) + // Wrapping may cause a vertical scrollbar to appear, which will change the width again. + this.props.model.setEditorWidthInChars(this.getScrollContainerClientWidthInBaseCharacters()) + this.suppressUpdates = false + } } // This method exists because it existed in the previous implementation and some