mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Serialize all TextEditor parameters needed for the DisplayLayer
This commit is contained in:
@@ -38,6 +38,29 @@ describe "TextEditor", ->
|
||||
expect(editor2.isFoldedAtBufferRow(4)).toBeTruthy()
|
||||
editor2.destroy()
|
||||
|
||||
it "restores the editor's layout configuration", ->
|
||||
editor.update({
|
||||
softTabs: true
|
||||
atomicSoftTabs: true
|
||||
tabLength: 12
|
||||
softWrapped: true
|
||||
softWrapAtPreferredLineLength: true
|
||||
softWrapHangingIndentLength: 8
|
||||
invisibles: {space: 'S'}
|
||||
showInvisibles: true
|
||||
editorWidthInChars: 120
|
||||
})
|
||||
|
||||
editor2 = TextEditor.deserialize(editor.serialize(), atom)
|
||||
|
||||
expect(editor2.getSoftTabs()).toBe(editor.getSoftTabs())
|
||||
expect(editor2.hasAtomicSoftTabs()).toBe(editor.hasAtomicSoftTabs())
|
||||
expect(editor2.getTabLength()).toBe(editor.getTabLength())
|
||||
expect(editor2.getSoftWrapColumn()).toBe(editor.getSoftWrapColumn())
|
||||
expect(editor2.getSoftWrapHangingIndentLength()).toBe(editor.getSoftWrapHangingIndentLength())
|
||||
expect(editor2.getInvisibles()).toEqual(editor.getInvisibles())
|
||||
expect(editor2.getEditorWidthInChars()).toBe(editor.getEditorWidthInChars())
|
||||
|
||||
describe "when the editor is constructed with the largeFileMode option set to true", ->
|
||||
it "loads the editor but doesn't tokenize", ->
|
||||
editor = null
|
||||
|
||||
@@ -338,21 +338,25 @@ class TextEditor extends Model
|
||||
serialize: ->
|
||||
tokenizedBufferState = @tokenizedBuffer.serialize()
|
||||
|
||||
deserializer: 'TextEditor'
|
||||
version: @serializationVersion
|
||||
id: @id
|
||||
softTabs: @softTabs
|
||||
firstVisibleScreenRow: @getFirstVisibleScreenRow()
|
||||
firstVisibleScreenColumn: @getFirstVisibleScreenColumn()
|
||||
selectionsMarkerLayerId: @selectionsMarkerLayer.id
|
||||
softWrapped: @isSoftWrapped()
|
||||
editorWidthInChars: @editorWidthInChars
|
||||
# TODO: Remove this forward-compatible fallback once 1.8 reaches stable.
|
||||
displayBuffer: {tokenizedBuffer: tokenizedBufferState}
|
||||
tokenizedBuffer: tokenizedBufferState
|
||||
largeFileMode: @largeFileMode
|
||||
displayLayerId: @displayLayer.id
|
||||
registered: @registered
|
||||
{
|
||||
deserializer: 'TextEditor'
|
||||
version: @serializationVersion
|
||||
|
||||
# TODO: Remove this forward-compatible fallback once 1.8 reaches stable.
|
||||
displayBuffer: {tokenizedBuffer: tokenizedBufferState}
|
||||
|
||||
tokenizedBuffer: tokenizedBufferState
|
||||
displayLayerId: @displayLayer.id
|
||||
selectionsMarkerLayerId: @selectionsMarkerLayer.id
|
||||
|
||||
firstVisibleScreenRow: @getFirstVisibleScreenRow()
|
||||
firstVisibleScreenColumn: @getFirstVisibleScreenColumn()
|
||||
|
||||
@id, @softTabs, @atomicSoftTabs, @tabLength, @softWrapped,
|
||||
@softWrapHangingIndentLength, @softWrapAtPreferredLineLength,
|
||||
@preferredLineLength, @mini, @editorWidthInChars, @width, @largeFileMode,
|
||||
@registered, @invisibles, @showInvisibles, @showIndentGuide
|
||||
}
|
||||
|
||||
subscribeToBuffer: ->
|
||||
@buffer.retain()
|
||||
|
||||
Reference in New Issue
Block a user