Skip to content

Commit

Permalink
Use raw buffer text (w/o invisibles) when testing decreaseIndentRegex
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbrunsfeld committed Jun 17, 2015
1 parent 3cdeaa8 commit 64dfda5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions spec/language-mode-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/language-mode.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 64dfda5

Please sign in to comment.