mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-22 00:19:24 +03:00
Use Editor.deserialize in Editor.prototype.copy and add a spec for it
This commit is contained in:
parent
da53fa1ba3
commit
54a15856bb
@ -26,6 +26,20 @@ describe "Editor", ->
|
||||
editor.insertText('x')
|
||||
expect(editor.lines.find('.line').length).toBe 1
|
||||
|
||||
describe ".copy()", ->
|
||||
it "builds a new editor with the same edit sessions, cursor position, and scroll position as the receiver", ->
|
||||
editor.setCursorScreenPosition([1, 1])
|
||||
|
||||
# prove this test covers serialization and deserialization
|
||||
spyOn(editor, 'serialize').andCallThrough()
|
||||
spyOn(Editor, 'deserialize').andCallThrough()
|
||||
|
||||
newEditor = editor.copy()
|
||||
expect(editor.serialize).toHaveBeenCalled()
|
||||
expect(Editor.deserialize).toHaveBeenCalled()
|
||||
expect(newEditor.buffer).toBe editor.buffer
|
||||
expect(newEditor.getCursorScreenPosition()).toEqual editor.getCursorScreenPosition()
|
||||
|
||||
describe "text rendering", ->
|
||||
it "creates a line element for each line in the buffer with the html-escaped text of the line", ->
|
||||
expect(editor.lines.find('.line').length).toEqual(buffer.numLines())
|
||||
|
@ -67,7 +67,7 @@ class Editor extends View
|
||||
{ viewClass: "Editor", @editSessions, @activeEditSessionIndex, @isFocused }
|
||||
|
||||
copy: ->
|
||||
new Editor(@serialize())
|
||||
Editor.deserialize(@serialize())
|
||||
|
||||
bindKeys: ->
|
||||
@on 'save', => @save()
|
||||
|
Loading…
Reference in New Issue
Block a user