Fix LanguageMode.proto.suggestedIndentationForBufferRow exception for row 0

This commit is contained in:
Nathan Sobo 2012-10-23 16:50:00 -06:00
parent b5b552737d
commit 4d9b777350
2 changed files with 10 additions and 1 deletions

View File

@ -109,6 +109,14 @@ describe "LanguageMode", ->
expect(languageMode.rowRangeForFoldAtBufferRow(2)).toBeNull()
expect(languageMode.rowRangeForFoldAtBufferRow(4)).toEqual [4, 7]
describe "suggestedIndentForBufferRow", ->
it "returns the suggested indentation based on auto-indent/outdent rules", ->
expect(languageMode.suggestedIndentForBufferRow(0)).toBe 0
expect(languageMode.suggestedIndentForBufferRow(1)).toBe 2
expect(languageMode.suggestedIndentForBufferRow(2)).toBe 4
expect(languageMode.suggestedIndentForBufferRow(9)).toBe 2
describe "coffeescript", ->
beforeEach ->
editSession = fixturesProject.buildEditSessionForPath('coffee.coffee', autoIndent: false)

View File

@ -92,7 +92,8 @@ class LanguageMode
return currentIndentation unless increaseIndentPattern = TextMateBundle.indentRegexForScope(scopes[0])
currentLine = @buffer.lineForRow(bufferRow)
precedingRow = @buffer.previousNonBlankRow(bufferRow)
return currentIndentation unless precedingRow = @buffer.previousNonBlankRow(bufferRow)
precedingLine = @buffer.lineForRow(precedingRow)
desiredIndentation = @buffer.indentationForRow(precedingRow)