Combat against empty range; fixes tests

This commit is contained in:
Ben Ogle
2013-07-17 18:22:41 -07:00
parent 2aca31988f
commit e43e8d156e
2 changed files with 3 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ describe "LanguageMode", ->
expect(languageMode.minIndentLevelForRowRange(5, 7)).toBe 2
expect(languageMode.minIndentLevelForRowRange(5, 6)).toBe 3
expect(languageMode.minIndentLevelForRowRange(9, 11)).toBe 1
expect(languageMode.minIndentLevelForRowRange(10, 10)).toBe 0
describe ".toggleLineCommentsForBufferRows(start, end)", ->
it "comments/uncomments lines in the given range", ->

View File

@@ -190,7 +190,8 @@ class LanguageMode
# Returns a {Number} of the indent level of the block of lines.
minIndentLevelForRowRange: (startRow, endRow) ->
indents = (@editSession.indentationForBufferRow(row) for row in [startRow..endRow] when @editSession.lineForBufferRow(row).trim())
Math.min(indents...)
min = Math.min(indents...)
if min == Infinity then 0 else min
# Indents all the rows between two buffer row numbers.
#