Call editor.setEditorWidthInChars only when the value changed

Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
Antonio Scandurra
2017-05-05 19:55:57 +02:00
committed by Nathan Sobo
parent a7f658a40f
commit 245f294cc3

View File

@@ -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