🐛 fix rowRangeForParagraphAtBufferRow using \S

This commit is contained in:
Sean Lee
2015-03-20 14:23:37 +08:00
committed by Ben Ogle
parent 59145581d7
commit 74caf89dd1
2 changed files with 11 additions and 3 deletions

View File

@@ -124,6 +124,11 @@ describe "LanguageMode", ->
// lines
var sort = function(items) {};
// comment line after fn
var nosort = function(items) {
return item;
}
};
'''
@@ -144,6 +149,9 @@ describe "LanguageMode", ->
range = languageMode.rowRangeForParagraphAtBufferRow(15)
expect(range).toEqual [[15,0], [15,26]]
range = languageMode.rowRangeForParagraphAtBufferRow(18)
expect(range).toEqual [[17,0], [19,1]]
describe "coffeescript", ->
beforeEach ->
waitsForPromise ->

View File

@@ -194,7 +194,7 @@ class LanguageMode
# Right now, a paragraph is a block of text bounded by and empty line or a
# block of text that is not the same type (comments next to source code).
rowRangeForParagraphAtBufferRow: (bufferRow) ->
return unless /\w/.test(@editor.lineTextForBufferRow(bufferRow))
return unless /\S/.test(@editor.lineTextForBufferRow(bufferRow))
if @isLineCommentedAtBufferRow(bufferRow)
isOriginalRowComment = true
@@ -207,14 +207,14 @@ class LanguageMode
startRow = bufferRow
while startRow > firstRow
break if @isLineCommentedAtBufferRow(startRow - 1) isnt isOriginalRowComment
break unless /\w/.test(@editor.lineTextForBufferRow(startRow - 1))
break unless /\S/.test(@editor.lineTextForBufferRow(startRow - 1))
startRow--
endRow = bufferRow
lastRow = @editor.getLastBufferRow()
while endRow < lastRow
break if @isLineCommentedAtBufferRow(endRow + 1) isnt isOriginalRowComment
break unless /\w/.test(@editor.lineTextForBufferRow(endRow + 1))
break unless /\S/.test(@editor.lineTextForBufferRow(endRow + 1))
endRow++
new Range([startRow, 0], [endRow, @editor.lineTextForBufferRow(endRow).length])