Don't make commented lines foldable based on the next line's indentation

Only the first line of a set of commented lines should be foldable, even
if some of the lines in the block are indented.
This commit is contained in:
Nathan Sobo 2014-01-20 14:29:08 -07:00
parent 86106cbf4d
commit 525b5c9978
2 changed files with 6 additions and 1 deletions

View File

@ -355,6 +355,11 @@ describe "LanguageMode", ->
expect(languageMode.isFoldableAtBufferRow(6)).toBe true
expect(languageMode.isFoldableAtBufferRow(17)).toBe false
it "does not return true for a line in the middle of a comment that's followed by an indented line", ->
expect(languageMode.isFoldableAtBufferRow(7)).toBe false
editor.buffer.insert([8, 0], ' ')
expect(languageMode.isFoldableAtBufferRow(7)).toBe false
describe "css", ->
beforeEach ->
atom.packages.activatePackage('language-source', sync: true)

View File

@ -190,7 +190,7 @@ class LanguageMode
# Private: Returns a {Boolean} indicating whether the given buffer row starts
# a a foldable row range due to the code's indentation patterns.
isFoldableCodeAtBufferRow: (bufferRow) ->
return false if @editor.isBufferRowBlank(bufferRow)
return false if @editor.isBufferRowBlank(bufferRow) or @isLineCommentedAtBufferRow(bufferRow)
nextNonEmptyRow = @editor.nextNonBlankBufferRow(bufferRow)
return false unless nextNonEmptyRow?
@editor.indentationForBufferRow(nextNonEmptyRow) > @editor.indentationForBufferRow(bufferRow)