Associate TokenizedLines with an ::indentLevel

This can be used to render the appropriate number of indent guide spans
for empty lines.
This commit is contained in:
David Graham & Nathan Sobo
2014-04-09 16:45:19 -06:00
committed by Nathan Sobo
parent d0a917ed14
commit 6997adece9
5 changed files with 70 additions and 10 deletions

View File

@@ -405,13 +405,7 @@ class Editor extends Model
#
# Returns a {Number}.
indentLevelForLine: (line) ->
if match = line.match(/^[\t ]+/)
leadingWhitespace = match[0]
tabCount = leadingWhitespace.match(/\t/g)?.length ? 0
spaceCount = leadingWhitespace.match(/[ ]/g)?.length ? 0
tabCount + (spaceCount / @getTabLength())
else
0
@displayBuffer.indentLevelForLine(line)
# Constructs the string used for tabs.
buildIndentString: (number) ->