Fix bug where text typed into empty buffer was on the wrong line.

This commit is contained in:
Nathan Sobo
2012-03-13 12:12:52 -06:00
parent d30e183edb
commit 8d432c02c1
2 changed files with 8 additions and 1 deletions

View File

@@ -874,6 +874,14 @@ describe "Editor", ->
expect(editor).not.toMatchSelector ':focus'
expect(editor.hiddenInput).toMatchSelector ':focus'
describe "construction", ->
it "assigns an empty buffer and correctly handles text input (regression coverage)", ->
editor = new Editor
expect(editor.buffer.path).toBeUndefined()
expect(editor.lines.find('.line').length).toBe 1
editor.insertText('x')
expect(editor.lines.find('.line').length).toBe 1
describe ".setBuffer(buffer)", ->
it "sets the cursor to the beginning of the file", ->
expect(editor.getCursorScreenPosition()).toEqual(row: 0, column: 0)

View File

@@ -45,7 +45,6 @@ class Editor extends View
@handleEvents()
@setBuffer(new Buffer)
@autoIndent = true
@lineCache = []
bindKeys: ->
window.keymap.bindKeys '*:not(.editor *)',