EditSession#indentLevelForLine detects tabs/spaces for each line

This allows folding, auto-indent, etc to work in a file in which *both* tabs and spaces are used to indent. Not that this is a good idea, but at least we handle it gracefully.
This commit is contained in:
Corey Johnson & Nathan Sobo
2012-10-26 11:52:37 -06:00
parent 4c24f4ea65
commit 487245311e

View File

@@ -123,10 +123,10 @@ class EditSession
@buffer.change([[bufferRow, 0], [bufferRow, currentIndentString.length]], newIndentString)
indentLevelForLine: (line) ->
if @softTabs
line.match(/^\s*/)?[0].length / @tabLength
else
if line.match(/^\t/)
line.match(/^\t*/)?[0].length
else
line.match(/^\s*/)?[0].length / @tabLength
buildIndentString: (number) ->
if @softTabs