Skip to content

Commit

Permalink
Fix indent guide indentation depth for tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
kiritsuku committed Feb 10, 2014
1 parent 3fc5608 commit 63e844f
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -174,9 +174,14 @@ trait IndentGuideGenerator {
def guidesOfRange(startLine: Int, endLine: Int): Seq[Guide] = {

/* indentation depth in number of characters */
def indentDepth(text: String) = text
.takeWhile(c => c == ' ' || c == '\t')
.foldLeft(0)((sum, c) => sum + (if (c == ' ') 1 else indentWidth))
def indentDepth(text: String) = {
val (sum, _) = text.takeWhile(c => c == ' ' || c == '\t').foldLeft((0, 0)) {
case ((sum, len), c) =>
val reminder = indentWidth - len % indentWidth
if (c == ' ') (sum + 1, len) else (sum + reminder, len + reminder)
}
sum
}

def decreaseFrom(line: Int) =
Iterator.iterate(line)(_ - 1).takeWhile(_ > 0)
Expand Down

0 comments on commit 63e844f

Please sign in to comment.