Use raw buffer text (w/o invisibles) when testing decreaseIndentRegex

This commit is contained in:
Max Brunsfeld
2015-06-17 12:07:42 -07:00
parent 3cdeaa8b51
commit 64dfda572d
2 changed files with 14 additions and 1 deletions

View File

@@ -101,6 +101,18 @@ describe "LanguageMode", ->
expect(languageMode.suggestedIndentForBufferRow(0)).toBe 0
expect(languageMode.suggestedIndentForBufferRow(1)).toBe 1
expect(languageMode.suggestedIndentForBufferRow(2)).toBe 2
expect(languageMode.suggestedIndentForBufferRow(5)).toBe 3
expect(languageMode.suggestedIndentForBufferRow(7)).toBe 2
expect(languageMode.suggestedIndentForBufferRow(9)).toBe 1
expect(languageMode.suggestedIndentForBufferRow(11)).toBe 1
it "does not take invisibles into account", ->
atom.config.set('editor.showInvisibles', true)
expect(languageMode.suggestedIndentForBufferRow(0)).toBe 0
expect(languageMode.suggestedIndentForBufferRow(1)).toBe 1
expect(languageMode.suggestedIndentForBufferRow(2)).toBe 2
expect(languageMode.suggestedIndentForBufferRow(5)).toBe 3
expect(languageMode.suggestedIndentForBufferRow(7)).toBe 2
expect(languageMode.suggestedIndentForBufferRow(9)).toBe 1
expect(languageMode.suggestedIndentForBufferRow(11)).toBe 1

View File

@@ -261,7 +261,8 @@ class LanguageMode
desiredIndentLevel += 1 if increaseIndentRegex.testSync(precedingLine) and not @editor.isBufferRowCommented(precedingRow)
return desiredIndentLevel unless decreaseIndentRegex = @decreaseIndentRegexForScopeDescriptor(scopeDescriptor)
desiredIndentLevel -= 1 if decreaseIndentRegex.testSync(tokenizedLine.text)
line = @buffer.lineForRow(bufferRow)
desiredIndentLevel -= 1 if decreaseIndentRegex.testSync(line)
Math.max(desiredIndentLevel, 0)