From 13c00995d4b32dcdc80d7f86956feffdbbc9fbe8 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 17 Aug 2016 11:57:35 -0600 Subject: [PATCH] Return default value of true from TextEditor.getAutoHeight When we need to check for unassigned in the deprecated code path, we can just read the instance variable directly to avoid getting the deafult. Signed-off-by: Antonio Scandurra --- spec/text-editor-spec.coffee | 4 ++-- src/text-editor-component.coffee | 4 ++-- src/text-editor.coffee | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index e1af7c46c..17ce81301 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -5507,8 +5507,8 @@ describe "TextEditor", -> expect(editor.getScrollPastEnd()).toBe(false) describe "auto height", -> - it "returns undefined by default but can be customized", -> - expect(editor.getAutoHeight()).toBeUndefined() + it "returns true by default but can be customized", -> + expect(editor.getAutoHeight()).toBe(true) editor.update({autoHeight: false}) expect(editor.getAutoHeight()).toBe(false) editor.update({autoHeight: true}) diff --git a/src/text-editor-component.coffee b/src/text-editor-component.coffee index 08fdbb9a8..8355c7fa5 100644 --- a/src/text-editor-component.coffee +++ b/src/text-editor-component.coffee @@ -57,7 +57,7 @@ class TextEditorComponent cursorBlinkResumeDelay: @cursorBlinkResumeDelay stoppedScrollingDelay: 200 lineTopIndex: lineTopIndex - autoHeight: @editor.getAutoHeight() ? true + autoHeight: @editor.getAutoHeight() @presenter.onDidUpdateState(@requestUpdate) @@ -759,7 +759,7 @@ class TextEditorComponent # auto-height in certain circumstances. This is legacy behavior that we # would rather not implement, but we can't remove it without risking # breakage currently. - unless @editor.getAutoHeight()? + unless @editor.autoHeight? {position, top, bottom} = getComputedStyle(@hostElement) hasExplicitTopAndBottom = (position is 'absolute' and top isnt 'auto' and bottom isnt 'auto') diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 89e5aaf49..42cfaa9b5 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -3542,7 +3542,7 @@ class TextEditor extends Model Grim.deprecate("This is now a view method. Call TextEditorElement::getHeight instead.") @height - getAutoHeight: -> @autoHeight + getAutoHeight: -> @autoHeight ? true setWidth: (width, reentrant=false) -> if reentrant