From 9511c952afe4f7c225bb1bee30fbccc7d7cd7509 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 3 Jun 2014 18:19:11 +0900 Subject: [PATCH] :lipstick: --- src/editor-component.coffee | 14 ++++++++++---- src/lines-component.coffee | 4 ++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/editor-component.coffee b/src/editor-component.coffee index 1660a0f5d..7dfc3b830 100644 --- a/src/editor-component.coffee +++ b/src/editor-component.coffee @@ -575,15 +575,18 @@ EditorComponent = React.createClass measureLineHeightAndCharWidthsIfNeeded: (prevState) -> if not isEqualForProperties(prevState, @state, 'lineHeight', 'fontSize', 'fontFamily') - @props.editor.batchUpdates => + {editor} = @props + + editor.batchUpdates => + oldDefaultCharWidth = editor.getDefaultCharWidth() + if @state.visible @measureLineHeightAndDefaultCharWidth() else @measureLineHeightAndDefaultCharWidthWhenShown = true - unless isEqualForProperties(prevState, @state, 'fontSize', 'fontFamily') - @refs.lines.clearScopedCharWidths() - @refs.lines.measureCharactersInNewLines() + unless oldDefaultCharWidth is editor.getDefaultCharWidth() + @remeasureCharacterWidths() else if @measureLineHeightAndDefaultCharWidthWhenShown and @state.visible and not prevState.visible @measureLineHeightAndDefaultCharWidth() @@ -592,6 +595,9 @@ EditorComponent = React.createClass @measureLineHeightAndDefaultCharWidthWhenShown = false @refs.lines.measureLineHeightAndDefaultCharWidth() + remeasureCharacterWidths: -> + @refs.lines.remeasureCharacterWidths() + measureScrollbars: -> @measuringScrollbars = false diff --git a/src/lines-component.coffee b/src/lines-component.coffee index 216129ac3..110e11fdc 100644 --- a/src/lines-component.coffee +++ b/src/lines-component.coffee @@ -209,6 +209,10 @@ LinesComponent = React.createClass editor.setLineHeightInPixels(lineHeightInPixels) editor.setDefaultCharWidth(charWidth) + remeasureCharacterWidths: -> + @clearScopedCharWidths() + @measureCharactersInNewLines() + measureCharactersInNewLines: -> [visibleStartRow, visibleEndRow] = @props.renderedRowRange node = @getDOMNode()