Skip to content

Commit

Permalink
Always suggest non-negative indent levels
Browse files Browse the repository at this point in the history
Close atom#668
  • Loading branch information
kevinsawicki committed Aug 1, 2013
1 parent 30f72c1 commit 684dec4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Fixed: Error when inserting newlines in CSS

* Improved: cmd-n now opens a new tab and cmd-shift-n now opens a new window.
* Added: Inspect Element context menu
* Fixed: Save As dialog now defaults to directory path of current editor
Expand Down
11 changes: 11 additions & 0 deletions spec/app/language-mode-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,14 @@ describe "LanguageMode", ->

fold2 = editSession.lineForScreenRow(5).fold
expect(fold2).toBeFalsy()

describe "css", ->
beforeEach ->
atom.activatePackage('source-tmbundle', sync: true)
atom.activatePackage('css-tmbundle', sync: true)
editSession = project.open('css.css', autoIndent: true)

describe "suggestedIndentForBufferRow", ->
it "does not return negative values (regression)", ->
editSession.setText('.test {\npadding: 0;\n}')
expect(editSession.suggestedIndentForBufferRow(2)).toBe 0
2 changes: 1 addition & 1 deletion src/app/language-mode.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class LanguageMode
return desiredIndentLevel unless decreaseIndentRegex = @decreaseIndentRegexForScopes(scopes)
desiredIndentLevel -= 1 if decreaseIndentRegex.test(currentLine)

desiredIndentLevel
Math.max(desiredIndentLevel, 0)

# Calculate a minimum indent level for a range of lines excluding empty lines.
#
Expand Down

0 comments on commit 684dec4

Please sign in to comment.