mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
Editor.initialize calls setEditorState to set buffer, cursor position, etc
This commit is contained in:
@@ -39,7 +39,7 @@ class Editor extends View
|
||||
softTabs: true
|
||||
tabText: ' '
|
||||
|
||||
initialize: (editorState={}) ->
|
||||
initialize: (editorState) ->
|
||||
requireStylesheet 'editor.css'
|
||||
requireStylesheet 'theme/twilight.css'
|
||||
|
||||
@@ -48,11 +48,8 @@ class Editor extends View
|
||||
@autoIndent = true
|
||||
@buildCursorAndSelection()
|
||||
@handleEvents()
|
||||
|
||||
buffer = editorState.buffer ? new Buffer
|
||||
@editorStatesByBufferId = {}
|
||||
@editorStatesByBufferId[buffer.id] = editorState
|
||||
@setBuffer(buffer)
|
||||
@setEditorState(editorState)
|
||||
|
||||
bindKeys: ->
|
||||
@on 'save', => @save()
|
||||
@@ -228,6 +225,11 @@ class Editor extends View
|
||||
@scroller.scrollTop(editorState.scrollTop ? 0)
|
||||
@scroller.scrollLeft(editorState.scrollLeft ? 0)
|
||||
|
||||
setEditorState: (editorState) ->
|
||||
buffer = editorState.buffer ? new Buffer
|
||||
@editorStatesByBufferId[buffer.id] = editorState
|
||||
@setBuffer(buffer)
|
||||
|
||||
getEditorState: ->
|
||||
buffer: @buffer
|
||||
cursorScreenPosition: @getCursorScreenPosition().copy()
|
||||
|
||||
Reference in New Issue
Block a user