mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Add autoWidth to TextEditor
This commit is contained in:
@@ -5516,6 +5516,14 @@ describe "TextEditor", ->
|
||||
editor.update({autoHeight: true})
|
||||
expect(editor.getAutoHeight()).toBe(true)
|
||||
|
||||
describe "auto width", ->
|
||||
it "returns false by default but can be customized", ->
|
||||
expect(editor.getAutoWidth()).toBe(false)
|
||||
editor.update({autoWidth: true})
|
||||
expect(editor.getAutoWidth()).toBe(true)
|
||||
editor.update({autoWidth: false})
|
||||
expect(editor.getAutoWidth()).toBe(false)
|
||||
|
||||
describe '.get/setPlaceholderText()', ->
|
||||
it 'can be created with placeholderText', ->
|
||||
newEditor = atom.workspace.buildTextEditor(
|
||||
|
||||
@@ -896,6 +896,9 @@ class TextEditorPresenter
|
||||
@updateScrollHeight()
|
||||
@updateEndRow()
|
||||
|
||||
didChangeAutoWidth: ->
|
||||
@emitDidUpdateState()
|
||||
|
||||
setContentFrameWidth: (contentFrameWidth) ->
|
||||
if @contentFrameWidth isnt contentFrameWidth or @editorWidthInChars?
|
||||
oldContentFrameWidth = @contentFrameWidth
|
||||
|
||||
@@ -127,7 +127,7 @@ class TextEditor extends Model
|
||||
@softTabs, @firstVisibleScreenRow, @firstVisibleScreenColumn, initialLine, initialColumn, tabLength,
|
||||
@softWrapped, @decorationManager, @selectionsMarkerLayer, @buffer, suppressCursorCreation,
|
||||
@mini, @placeholderText, lineNumberGutterVisible, @largeFileMode, @clipboard,
|
||||
@assert, grammar, @showInvisibles, @autoHeight, @scrollPastEnd, @editorWidthInChars,
|
||||
@assert, grammar, @showInvisibles, @autoHeight, @autoWidth, @scrollPastEnd, @editorWidthInChars,
|
||||
@tokenizedBuffer, @displayLayer, @invisibles, @showIndentGuide, @softWrapHangingIndentLength,
|
||||
@softWrapped, @softWrapAtPreferredLineLength, @preferredLineLength
|
||||
} = params
|
||||
@@ -144,6 +144,7 @@ class TextEditor extends Model
|
||||
@selections = []
|
||||
@hasTerminatedPendingState = false
|
||||
|
||||
@autoWidth ?= false
|
||||
@autoHeight ?= true
|
||||
@mini ?= false
|
||||
@scrollPastEnd ?= true
|
||||
@@ -320,6 +321,10 @@ class TextEditor extends Model
|
||||
@autoHeight = value
|
||||
@editorElement?.didChangeAutoHeight()
|
||||
|
||||
when 'autoWidth'
|
||||
if value isnt @autoWidth
|
||||
@autoWidth = value
|
||||
@presenter?.didChangeAutoWidth()
|
||||
else
|
||||
throw new TypeError("Invalid TextEditor parameter: '#{param}'")
|
||||
|
||||
@@ -3552,6 +3557,9 @@ class TextEditor extends Model
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::getWidth instead.")
|
||||
@width
|
||||
|
||||
getAutoWidth: ->
|
||||
@autoWidth
|
||||
|
||||
# Experimental: Scroll the editor such that the given screen row is at the
|
||||
# top of the visible area.
|
||||
setFirstVisibleScreenRow: (screenRow, fromView) ->
|
||||
|
||||
Reference in New Issue
Block a user