Detect softTabs/hardTabs when an EditSession is created

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-10-26 12:09:51 -06:00
parent 3a067bcd71
commit adf00b60f3
4 changed files with 28 additions and 3 deletions

View File

@@ -352,6 +352,12 @@ class Buffer
return row unless @isRowBlank(row)
null
usesSoftTabs: ->
for line in @getLines()
if match = line.match(/^\s/)
return match[0][0] != '\t'
undefined
logLines: (start=0, end=@getLastRow())->
for row in [start..end]
line = @lineForRow(row)

View File

@@ -39,9 +39,9 @@ class EditSession
softTabs: true
softWrap: false
constructor: ({@project, @buffer, @tabLength, @autoIndent, @softTabs, @softWrap }) ->
constructor: ({@project, @buffer, @tabLength, @autoIndent, softTabs, @softWrap }) ->
@id = @constructor.idCounter++
@softTabs ?= true
@softTabs = @buffer.usesSoftTabs() ? softTabs ? true
@languageMode = new LanguageMode(this, @buffer.getExtension())
@displayBuffer = new DisplayBuffer(@buffer, { @languageMode, @tabLength })
@tokenizedBuffer = @displayBuffer.tokenizedBuffer