diff --git a/spec/text-editor-element-spec.coffee b/spec/text-editor-element-spec.coffee index c60a9762f..0677f0284 100644 --- a/spec/text-editor-element-spec.coffee +++ b/spec/text-editor-element-spec.coffee @@ -267,6 +267,26 @@ describe "TextEditorElement", -> element.getModel().setMini(false) expect(element.hasAttribute('mini')).toBe false + describe "on TextEditor::onDidChangeAutoHeight", -> + it "changes the element's height", -> + element = new TextEditorElement + jasmine.attachToDOM(element) + expect(element.style.height).toBe('') + element.getModel().setAutoHeight(false) + + waitsForPromise -> + atom.views.getNextUpdatePromise() + + runs -> + expect(element.style.height).toBe('100%') + element.getModel().setAutoHeight(true) + + waitsForPromise -> + atom.views.getNextUpdatePromise() + + runs -> + expect(element.style.height).toBe('') + describe "events", -> element = null diff --git a/src/text-editor-element.coffee b/src/text-editor-element.coffee index 1de43c6bd..4ab90a808 100644 --- a/src/text-editor-element.coffee +++ b/src/text-editor-element.coffee @@ -38,7 +38,8 @@ class TextEditorElement extends HTMLElement @setAttribute('tabindex', -1) initializeContent: (attributes) -> - @resetAutoHeight() + unless @getModel().getAutoHeight() + @style.height = "100%" if @config.get('editor.useShadowDOM') @useShadowDOM = true @@ -193,8 +194,11 @@ class TextEditorElement extends HTMLElement @removeAttribute("mini") resetAutoHeight: -> - unless @getModel().getAutoHeight() - @style.height = "100%" + @views.updateDocument => + if @getModel().getAutoHeight() + @style.height = "" + else + @style.height = "100%" addEncodingAttribute: -> @dataset.encoding = @model.getEncoding()