mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Uncomment lines that match non-whitespace prefix of comment regex
This commit is contained in:
@@ -1360,6 +1360,19 @@ describe "EditSession", ->
|
||||
editSession.toggleLineCommentsInSelection()
|
||||
expect(buffer.lineForRow(4)).toBe " while(items.length > 0) {"
|
||||
|
||||
it "uncomments when the line lacks the trailing whitespace in the comment regex", ->
|
||||
editSession.setSelectedBufferRange([[10, 0], [10, 0]])
|
||||
editSession.toggleLineCommentsInSelection()
|
||||
|
||||
expect(buffer.lineForRow(10)).toBe "// "
|
||||
expect(editSession.getSelectedBufferRange()).toEqual [[10, 3], [10, 3]]
|
||||
editSession.backspace()
|
||||
expect(buffer.lineForRow(10)).toBe "//"
|
||||
|
||||
editSession.toggleLineCommentsInSelection()
|
||||
expect(buffer.lineForRow(10)).toBe ""
|
||||
expect(editSession.getSelectedBufferRange()).toEqual [[10, 0], [10, 0]]
|
||||
|
||||
describe ".undo() and .redo()", ->
|
||||
it "undoes/redoes the last change", ->
|
||||
editSession.insertText("foo")
|
||||
|
||||
@@ -49,7 +49,9 @@ class LanguageMode
|
||||
scopes = @tokenizedBuffer.scopesForPosition(range.start)
|
||||
return unless commentString = TextMateBundle.lineCommentStringForScope(scopes[0])
|
||||
|
||||
commentRegex = new OnigRegExp("^\s*" + _.escapeRegExp(commentString))
|
||||
commentRegexString = _.escapeRegExp(commentString)
|
||||
commentRegexString = commentRegexString.replace(/(\s+)$/, '($1)?')
|
||||
commentRegex = new OnigRegExp("^\s*#{commentRegexString}")
|
||||
|
||||
shouldUncomment = commentRegex.test(@editSession.lineForBufferRow(range.start.row))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user