Add autoHeight setting.

This commit is contained in:
joshaber
2016-02-25 16:05:57 -05:00
parent dd780a7c5a
commit dd83619c45
2 changed files with 11 additions and 2 deletions

View File

@@ -344,6 +344,10 @@ class TextEditorElement extends HTMLElement
@style.height = height + "px"
@component.measureDimensions()
disableAutoHeight: ->
@style.height = "100%"
@component.measureDimensions()
getHeight: ->
@offsetHeight

View File

@@ -97,7 +97,7 @@ class TextEditor extends Model
softWrapped, @displayBuffer, @selectionsMarkerLayer, buffer, suppressCursorCreation,
@mini, @placeholderText, lineNumberGutterVisible, largeFileMode, @config,
@notificationManager, @packageManager, @clipboard, @viewRegistry, @grammarRegistry,
@project, @assert, @applicationDelegate, @pending, grammarName, ignoreInvisibles
@project, @assert, @applicationDelegate, @pending, grammarName, ignoreInvisibles, @autoHeight
} = params
throw new Error("Must pass a config parameter when constructing TextEditors") unless @config?
@@ -116,6 +116,7 @@ class TextEditor extends Model
@cursors = []
@cursorsByMarkerId = new Map
@selections = []
@autoHeight ?= true
buffer ?= new TextBuffer
@displayBuffer ?= new DisplayBuffer({
@@ -3152,7 +3153,11 @@ class TextEditor extends Model
# Get the Element for the editor.
getElement: ->
@editorElement ?= new TextEditorElement().initialize(this, atom)
if not @editorElement?
@editorElement = new TextEditorElement().initialize(this, atom)
if not @autoHeight
@editorElement.disableAutoHeight()
@editorElement
# Essential: Retrieves the greyed out placeholder of a mini editor.
#