From 57fd553c695701c3fa3111863ade834ed2feb188 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 4 Jun 2015 15:09:15 +0200 Subject: [PATCH] Use `clientHeight` for line-numbers and lines containers --- src/gutter-component-helpers.coffee | 3 --- src/line-number-gutter-component.coffee | 4 ++++ src/lines-component.coffee | 6 +++--- src/text-editor-presenter.coffee | 2 ++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gutter-component-helpers.coffee b/src/gutter-component-helpers.coffee index 499b90552..d938ed10d 100644 --- a/src/gutter-component-helpers.coffee +++ b/src/gutter-component-helpers.coffee @@ -15,9 +15,6 @@ module.exports = # Sets scrollHeight, scrollTop, and backgroundColor on the given domNode. setDimensionsAndBackground: (oldState, newState, domNode) -> - if newState.scrollHeight isnt oldState.scrollHeight - domNode.style.height = newState.scrollHeight + 'px' - oldState.scrollHeight = newState.scrollHeight if newState.backgroundColor isnt oldState.backgroundColor domNode.style.backgroundColor = newState.backgroundColor diff --git a/src/line-number-gutter-component.coffee b/src/line-number-gutter-component.coffee index 7b68c2acd..2d0d5049f 100644 --- a/src/line-number-gutter-component.coffee +++ b/src/line-number-gutter-component.coffee @@ -48,6 +48,10 @@ class LineNumberGutterComponent extends TiledComponent setDimensionsAndBackground(@oldState.styles, @newState.styles, @lineNumbersNode) + if @newState.height isnt @oldState.height + @lineNumbersNode.style.height = @newState.height + "px" + @oldState.height = @newState.height + if @newState.maxLineNumberDigits isnt @oldState.maxLineNumberDigits @updateDummyLineNumber() @oldState.styles = {} diff --git a/src/lines-component.coffee b/src/lines-component.coffee index 92823daf1..039425f7e 100644 --- a/src/lines-component.coffee +++ b/src/lines-component.coffee @@ -33,9 +33,9 @@ class LinesComponent extends TiledComponent @oldState.indentGuidesVisible isnt @newState.indentGuidesVisible beforeUpdateSync: (state) -> - if @newState.scrollHeight isnt @oldState.scrollHeight - @domNode.style.height = @newState.scrollHeight + 'px' - @oldState.scrollHeight = @newState.scrollHeight + if @newState.clientHeight isnt @oldState.clientHeight + @domNode.style.height = @newState.clientHeight + 'px' + @oldState.clientHeight = @newState.clientHeight if @newState.backgroundColor isnt @oldState.backgroundColor @domNode.style.backgroundColor = @newState.backgroundColor diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index df58ea76c..6188eb144 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -453,6 +453,7 @@ class TextEditorPresenter return updateLineNumberGutterState: -> + @lineNumberGutter.height = @clientHeight @lineNumberGutter.maxLineNumberDigits = @model.getLineCount().toString().length updateCommonGutterState: -> @@ -656,6 +657,7 @@ class TextEditorPresenter clientHeight = @height - @horizontalScrollbarHeight unless @clientHeight is clientHeight @clientHeight = clientHeight + @state.content.clientHeight = @clientHeight @updateScrollHeight() @updateScrollTop()