Pass tabText into EditSession explicitly on construction

This commit is contained in:
Nathan Sobo
2012-06-13 11:13:41 -06:00
parent 09a05141d0
commit 4ccf976501
4 changed files with 17 additions and 8 deletions

View File

@@ -7,10 +7,14 @@ describe "EditSession", ->
beforeEach ->
fakeEditor =
calcSoftWrapColumn: ->
tabText: ' '
buffer = new Buffer(require.resolve('fixtures/sample.js'))
editSession = new EditSession(editor: fakeEditor, buffer: buffer, autoIndent: false)
editSession = new EditSession(
editor: fakeEditor
buffer: buffer
tabText: ' '
autoIndent: false
)
lineLengths = buffer.getLines().map (line) -> line.length
describe "cursor movement", ->

View File

@@ -9,8 +9,7 @@ describe "Selection", ->
buffer = new Buffer(require.resolve('fixtures/sample.js'))
fakeEditor =
calcSoftWrapColumn: ->
tabText: ' '
editSession = new EditSession(editor: fakeEditor, buffer: buffer)
editSession = new EditSession(editor: fakeEditor, buffer: buffer, tabText: ' ')
selection = editSession.getSelection()
describe ".deleteSelectedText()", ->

View File

@@ -15,6 +15,7 @@ class EditSession
session = new EditSession(
editor: editor
buffer: buffer
tabText: editor.tabText
autoIndent: editor.autoIndent
softTabs: editor.softTabs
)
@@ -31,10 +32,9 @@ class EditSession
autoIndent: true
softTabs: true
constructor: ({@editor, @buffer, @autoIndent}) ->
constructor: ({@editor, @buffer, @tabText, @autoIndent}) ->
@id = @constructor.idCounter++
@tabText = @editor.tabText
@renderer = new Renderer(@buffer, { softWrapColumn: @editor.calcSoftWrapColumn(), tabText: @editor.tabText })
@renderer = new Renderer(@buffer, { softWrapColumn: @editor.calcSoftWrapColumn(), tabText: @tabText })
@cursors = []
@selections = []
@addCursorAtScreenPosition([0, 0])

View File

@@ -354,7 +354,13 @@ class Editor extends View
index = @editSessionIndexForBuffer(buffer)
unless index?
index = @editSessions.length
@editSessions.push(new EditSession(editor: this, buffer: buffer, autoIndent: @autoIndent, softTabs: @softTabs))
@editSessions.push(new EditSession(
editor: this
buffer: buffer
tabText: @tabText
autoIndent: @autoIndent
softTabs: @softTabs
))
@setActiveEditSessionIndex(index)